I'm setting up a News page as my site blog, and I want it to have a different sidebar from the one already used on the rest of the site.

So far, I've managed to add a new widget area for my sidebar to the functions.php in the child theme, and I created a News page template for use by the News page that uses the new widget area.

The new sidebar now works great on my News page, but now I want that sidebar to also display (instead of the sidebar used by the rest of the site) on single posts, on post categories, and on post archive pages (eg slug 2017/05)

I'm struggling to understand the best way to do this without creating lots of templates and without affecting other parts of the site. I've looked at the template hierarchy, but it doesn't make enough sense to me at the moment.

1 Answer 1


Thinking about this problem some more, and meditating on the Wordpress template hierarchy below, I came up with a solution to my own problem.

I found that if I looked at the left side of the template hierarchy diagram and found the page type I was interested in, I could then work my way as far to the right side of it as I could without affecting other site pages. I also looked for existing templates in use by my Child Theme, and my parent theme, to ensure that chosen file wouldn't be overridden.

Clearly the solution is going to vary depending on the child and parent theme files that exist, but this worked for me:

  1. No category.php file existed in my child or parent theme, so I looked at archive.php which was further to the right on the diagram.
  2. archive.php existed in my parent theme, but not my child theme, so I copied it to my child theme and updated the sidebar template to use my new side bar. This changed my sidebar for the category and archive pages.
  3. Single posts still used the old sidebar. I suspected other content on the site might be using the single.php template, so I tried overriding just single-post.php. This file didn't exist in my child theme, but did in the parent, so again I copied it to my child theme and updated it to use the new sidebar template.

There was a search field appearing in the main content heading in an unexpected place after my changes, so I hid that with some CSS and everything looks great.

Wordpress Template Hierarchy as at May 2017: Wordpress Template Hierarchy as at May 2017

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.