WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Different Sidebar for Single Post depending on the Category ID of the Post (4 posts)

  1. nelson-ray
    Member
    Posted 7 years ago #

    Hi...
    I would like to know how to change the sidebar for a single post view...depending on what category that single post view belongs to. I have 4 different categories on my blog and each has its own modified sidebar. It works great but when someone clicks on a post to view in a single post view...the sidebar changes to the default sidebar rather then staying with the corresponding category sidebar.

    In single.php I am guessing <?php get_sidebar(); ?> needs to be modified to check if it belongs in category 1,2,3 or 4 and then show the corresponding sidebar1.php, sidebar2.php, sidebar3.php, or sidebar4.php

    any help one how I could implement this? Thank you...

  2. Chris_K
    Member
    Posted 7 years ago #

    Would this plugin help? http://guff.szub.net/2005/07/21/post-templates-by-category/

    Otherwise, maybe have a look at the in_category() tag: http://codex.wordpress.org/Template_Tags/in_category

  3. nelson-ray
    Member
    Posted 7 years ago #

    hey...that plugin works nicely...thanks you very much! (huge itch scratched...)

  4. Chris_K
    Member
    Posted 7 years ago #

    good deal! Mark this post as [Resolved] then? (toggle at top of the page)

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags