Archive-{post-type}.php template not working

I’ve read the documentation but no luck. What I’m trying to do is to have different template for each cpt like archive-{post-type}.php which I copied from index.php. But it doesn’t show up, instead the index.php was showing. But when I installed toolset plugin the archive-{post-type}.php seems detected by the plugin. So meaning I’m doing the right process, but still it’s not showing the archive template.

Anyway I’ve added the line of code below from the documentation to be able to have have different base code for archive and I tried creating base-{post-type}.php but this doesn’t show up too! Seems weird. :frowning:

add_filter('sage/wrap_base', __NAMESPACE__ . 'sage_wrap_base_cpts'); // Add our function to the sage/wrap_base filter

function sage_wrap_base_cpts($templates) {
  $cpt = get_post_type(); // Get the current post type
  if ($cpt) {
     array_unshift($templates, 'base-' . $cpt . '.php'); // Shift the template to the front of the array
  }
  return $templates; // Return our modified array with base-$cpt.php at the front of the queue
}

P.S: I’m using Sage 8.4.2 and latest version of WP.

My very bad! I’ve solved the problem by just categorizing the items/posts from my Custom Post Type(called Sermon). I just thought that my other posts from post type itself(which I already categorized as sermon) should be using the same wrapper/template from archive-sermon.php as well as from base-sermon.php.

So meaning, after I deleted and moved my post items(from built in post-type) to my new cpt called sermon and categorizing them as sermon again, the items are now showing up with the custom wrapper I made for each cpts!

My bad! I’m so noob! But I know this is just a part of my learning process using Wordpress as well as this awesome Theme. Thanks for reading. :slight_smile:

Randy :slight_smile:

2 Likes