Force Category Template

About

WordPress allows you to specify a template for a specific category. This is done by making a template and naming it category-X.php where X is the numeric ID of the category. This template is only used when looking at the category view. Several people have told me that they would like individual entries to also use this template. That is, an entry in category 3 should use category-3.php when it is viewed directly. This plugin enables that behavior. Note that this template will now be used for both the category AND the single view of posts in that category, so you will have to use the is_category() and is_single() functions if you want further differentiation.

For example:

<?php if ( is_category() ) { ?>
This is the category view
<?php } ?>

<?php if ( is_single() ) { ?>
This is the individual post view
<?php } ?>

Download

Instructions

Download the plugin, and upload to your /wp-content/plugins/ directory. Activate it via WordPress’ admin panel. You’re done!

Versions

  • Version 0.1 Initial release

Donate

I've spent a lot of time writing this code and supporting it. If you derive some benefit from this code, please consider showing your gratitute in a more tangible way. Thanks!

Donate with PayPalAmazon.com Wishlist