I've got a category template: category-projects.php
This category has subcategories, but they're refering to the template category.php for instructions instead of the parent category. How do I make subcategories refer to parent category templates in the cascading order of template references?
*Note, I'm talking about category level urls, not posts.
Activate the plugin through the 'Plugins' screen in WordPress. On the 'Widgets' sub-menu of 'Appearance' you will find a new widget type called 'Sub Category'. Add one or more of these to your themes widget display areas. For each widget you add, decide what and how you'd like it to display.
Click on Appearance > Customize. Then go to WooCommerce > Product Catalog. Select “show subcategories” from Category Display. Click on Save Changes.
Richard's answer does work but it will heavily interfere with other plugins.
I found a better alternative using add_filter
& template_include
as the example below
add_filter( 'template_include', 'my_callback' );
function my_callback( $original_template ) {
if ( some_condition() ) {
return SOME_PATH . '/some-custom-file.php';
} else {
return $original_template;
}
}
Credit to https://markjaquith.wordpress.com/2014/02/19/template_redirect-is-not-for-loading-templates/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With