WordPress.org

Ready to get started?Download WordPress

Forums

How-to: Get category related posts in Single template's sidebar (3 posts)

  1. vitalis
    Member
    Posted 7 years ago #

    Under 'News' category I have modified the sidebar so that it only shows posts under this category. Great.

    Problem: When I click on a news article it brings me to its single page but the sidebar changes.

    How do I display category-related posts in the the Single Template (single.php)?

    Is it possible to do something like the following in the single template?

    if is_category 'news' -> my_news_sidebar.php
    else -> sidebar.php

    I've searched in Google and looked in the documentation to no avail. For some reason I can't get this apparently easy thing to work. Thanks in advanced.

  2. Kafkaesqui

    Posted 7 years ago #

    My Post Templates by Category plugin may be useful here:

    http://guff.szub.net/2005/07/21/post-templates-by-category/

    With it you can set up a separate template based on your single.php but for posts in that specific category (i.e. with the my_news_sidebar.php included in it).

  3. vitalis
    Member
    Posted 7 years ago #

    WOW! At last! Should have asked here earlier. Thanks so much! Cheers

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.