Forums

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

  1. cableghost
    Member
    Posted 8 months 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 8 months 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

Reply

You must log in to post.

About this Topic