Support » Themes and Templates » Excluding Archive & Category Widgets from Pages

  • KIntheHouse



    Is there way to exclude Archives & Categories widget from showing up in the Page sidebar? I want them to show up only in the blog posts but not the pages.

    Thanks in advance.

Viewing 1 replies (of 1 total)
  • Clicknathan


    Assuming you have more widgets than just the Archives & Categories ones you’re referring to, you could do the following:

    1. Remove the two widgets in question and replace them with actual code in your sidebar. The code to add Archives is here and Categories is here.
    2. You should end up with some code that looks something like:
      <li><?php wp_list_categories(); ?></li>
      <li><?php wp_get_archives(); ?></li>
    3. You’ll then want to use conditional tags to tell WordPress not to show that information on your Pages. So you’ll add some code around the above code, ending up with something like:
      <?php if (!is_page()) { ?>
      <li><?php wp_list_categories(); ?></li>
      <li><?php wp_get_archives(); ?></li>
      <?php }  ?>

    Those various <li> bits are just examples of what you might see in the default template, and you may want to change them for your own theme. Hope that helps!

Viewing 1 replies (of 1 total)
  • The topic ‘Excluding Archive & Category Widgets from Pages’ is closed to new replies.