I have a custom taxonomy/custom post category and I'm trying to write a function, which removes the sidebar from the archive pages, only when there's a (custom) taxonomy match. The match part isn't the issue, but I'm unable to silence WP's get_sidebar() (triggered by arhive.php). The best result I got, removed not only the sidebar, but also the footer and admin header menu... which is a bit too much.

Does anyone know how to disable arhive.php's get_sidebar() via functions.php?

2 Answers 2


Use custom archive template for your custom taxonomy. so if your taxonomy is 'XYZ' , its archive page will be taxonomy-XYZ.php. Now in this custom archive page for your custom taxonomy, you can choose to add /remove sidebar as per your requirement.

  • Thank you very much @FiazHusyn for breaking my obsessive search "spell", trying to find a function-based method! Your answer confirms that the template approach is indeed the best approach. Sigh, now I can finally start to untangle the knots in my head. I'll post my approach as an answer.
    – Ralph
    Nov 15, 2014 at 15:42
  • Glad to have helped :)
    – Fiaz Husyn
    Nov 29, 2014 at 20:09

As suggested by @FiazHusyn, I went for the custom taxonomy archive template approach. On top of that I gave the custom taxonomy archive template, it's own custom sidebar template. Here's how to do that:

  1. Copy/paste your theme's archive.php and rename the copy to taxonomy-your_taxname.php;
  2. Copy/paste your theme's sidebar.php and rename the copy to sidebar-your_taxname.php;
  3. Open taxonomy-your_taxname.php, look for get_sidebar(), replace it with get_sidebar('your_taxname') and save/close the file;
  4. Upload taxonomy-your_taxname.php and sidebar-your_taxname.php to your theme's root folder on your server.

That's it! You should now be able to customize both the custom archive and sidebar templates, relating to your custom taxonomy.

Don't want a sidebar?

In case you don't want a sidebar for your custom archive template, simply remove/comment out get_sidebar(); in taxonomy-your_taxname.php.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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