WordPress.org

Support

Support » How-To and Troubleshooting » Indentify a posts category ?

Indentify a posts category ?

  • thornomad

    @thornomad

    Hi,

    I want my viewers to get different page content based on the category of the post(s) they are viewing. I am able to get special “top text” information for when they view a category, but how I can adjust the sidebar content and then top category to match a particular single post as well?

    What are the functions I need to have it run an if/else on the post itself and determine its category ? Thanks

    Currenly, in my index.php file I have:

    <?php if (have_posts()) : ?><br />
    <?php $post = $posts[0]; ?><br />
    <?php if (is_category()) { ?><br />
    <h2 class="pagetitle"><?php echo single_cat_title(); ?> - <?php echo category_description(); ?></h2><br />
    <?php } elseif (is_search()) { ?><br />
    <h2 class="pagetitle">Search Results</h2><br />
    <?php } else { ?><br />
    <h2 class="pagetitle">Download free music and audiobooks and read the blog<br />All content written and performed by Damon Timm</h2><br />
    <?php } ?>

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Indentify a posts category ?’ is closed to new replies.
Skip to toolbar