Custom template not parsed and answsers with the raw code

[ad_1]

Hello,

Using a category_template filter to route the template picking from a custom condition :

<?php
add_filter('category_template', function ( $template ) {
  $category = get_queried_object();
  // custom condition 
  if( $category->parent == 1 ) {
    $template = locate_template('templates/category-1.html');
  }

  return $template;
});

When requesting the category 1 page directly, everything goes right so it’s not about the template format itself.

But, when requesting one of its child and entering the custom condition, it’s like the template is not seen as a template and the html answer shows the raw content of the file :

<!-- wp:template-part {"slug":"header","tagName":"header"} /-->
[…]
<!-- wp:template-part {"slug":"footer","tagName":"footer"} /-->

What am I missing ?

  • This topic was modified 2 hours, 11 minutes ago by challet.

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer