WordPress.org

Support

Support » How-To and Troubleshooting » How-to: Get category related posts in Single template’s sidebar

How-to: Get category related posts in Single template’s sidebar

  • 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.

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How-to: Get category related posts in Single template’s sidebar’ is closed to new replies.