• I am using the featured image of a page as the header banner so that a different image displays on each page (I’ve set a default image for the header div so if there’s no featured image set it will display the background image).

    This is working nicely however I want to set it so that if the post displayed is from the category “product” it displays a default div background instead of the featured image for that post.

    Can someone help me with the code for this?

    So basically what I want is to know how to say…

    if post is from category “product”
    <div id=”featured-header”></div>
    else

    <?php $image_id = get_post_thumbnail_id(); ?>
    <?php $image_url = wp_get_attachment_image_src($image_id,'small');   ?>
    <div id="featured-header"><img src="<?php echo $image_url[0]; ?>" alt=""></div>

    Thanks.

  • The topic ‘Featured img for header except for specific category’ is closed to new replies.