WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Present Content in Div based on Post Category (2 posts)

  1. cableghost
    Member
    Posted 2 years ago #

    Is there a simple method/code to present content in a div based on the category of the post? If so, please point me in the right direction.

  2. cableghost
    Member
    Posted 2 years ago #

    I found a solution that works. I edited the following code and placed within div:

    <?php if (in_category('1')) { ?>
    <img src="http://www.mysite.com/images/header1.jpg">
    <?php } elseif (is_category('Category Name')) { ?>
    <img src="http://www.mysite.com/images/header1.jpg">
    <?php } else { ?>
    <img src="http://www.mysite.com/images/header2.jpg">
    <?php } ?>

    Found this code here: WordPress Tip: Swapping Images Based on Category

Topic Closed

This topic has been closed to new replies.

About this Topic