Archived topic
Set Automatic Featured Image for Posts in Particular Category
5 replies · Started by Naman Nepal on August 10, 2018
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.
Hi there,
Have you tried this?
https://wordpress.org/plugins/default-featured-image/
Looks like their FAQ section has what you need.
Let me know if this helps :)
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.
Tom gave it a shot here but doesn't look it was solved:
https://generatepress.com/forums/topic/default-fallback-featured-image/
Did you look at the FAQ section of that plugin?
They have functions to for "Use a different image for some categories".
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.
Just making sure you've seen my reply above since we replied at the same time:
https://generatepress.com/forums/topic/set-automatic-featured-image-for-posts-in-particular-category/#post-645193