skip to Main Content

Custom Template for Blog Category

Recently I was asked to setup the Daily Bible Reading for Compass Bible Church, AV in the form of blog posts. The old DBR page had a menu bar and a header graphic that both would need to be in each blog post. Modifying the blog post template would be the quickest way to incorporate the two elements in each post.

The problem with adding those two elements is that any blog post on the website would inherit the custom changes since there is only one blog post template.

Another option would be to create a separate theme for the subsite (WordPress Multisite) however, that would cause twice as much work when there is a theme update.

The solution was quite easy; creating a new template that had the custom coding for the dbr category.

All you need to do is duplicate your blog post template, rename it, and add your custom html.

Then add this coding to the top of your blog post template:

[php]
<?php
if(in_category(‘dbr’)) {

include ‘single-standard-dbr.php’;
} else {

?>

/* Template Coding goes here */

<?php } ?> /* End of DBR */
[/php]

Finally, re-upload both files to the original directory location.

Leave a Reply

Your email address will not be published. Required fields are marked *

Back To Top