Site logo

Archived topic

Set Automatic Featured Image for Posts in Particular Category

5 replies · Started by Naman Nepal on August 10, 2018

Viewing posts 1–6 of 6

Hi,

I was looking for a way to setup default featured image (if they are not set particularly) for posts in a particular category.

For example: I have a category named "Press" where there are 100s of press releases and no featured image. I'd like to setup the same featured image for each of the articles under the "press" category.

I looked into a few plugins but did not find any that let me setup conditional featured images.

Can you help here?

Thanks.

Is there a function that will let me do that without the need to using the plugin? I found a couple but I do not have knowledge in creating conditional statement within functions.

For example I use this to setup default featured image:

<?php if ( has_post_thumbnail() ) {
the_post_thumbnail();
} else { ?>
/images/default-image.jpg" alt="<?php the_title(); ?>" />
<?php } ?>

But I want it to be conditioned for only that one category.

This archived topic is closed to new replies.