Skip Navigation

[Resolved] is it possible to set a default featured image for a custom post type

This thread is resolved. Here is a description of the problem and solution.

Problem:

I have a cred form for meal inputs and there is an optional field to add a featured image. I'd like this not to be blank if the user does not add an image, as this messes up views layouts of the meals in a loop with the featured image shown.

Is there a way to have a fall back default so that each post in the loop for a given Meal category has a featured image.

Solution:

In the post loop, I suggest you use [wpv-conditional] shortcode to check if featured image is empty, then display a default image, for example:

https://toolset.com/forums/topic/is-it-possible-to-set-a-default-featured-image-for-a-custom-post-type/#post-1141102

Relevant Documentation:

This support ticket is created 6 years ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Our next available supporter will start replying to tickets in about 2.28 hours from now. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 3 replies, has 2 voices.

Last updated by Luo Yang 6 years ago.

Assisted by: Luo Yang.

Author
Posts
#1140654

I have a cpt for member meals and would like to set a default featured image for each meal category under the cpt taxonomy which is Meal Category, of which there are several options; breakfast, lunch, dinner etc.

I have a cred form for meal inputs and there is an optional field to add a featured image. I'd like this not to be blank if the user does not add an image, as this messes up views layouts of the meals in a loop with the featured image shown.

Is there a way to have a fall back default so that each post in the loop for a given Meal category has a featured image.

thanks,

Iain

#1141102

Hello,

In the post loop, I suggest you use [wpv-conditional] shortcode to check if featured image is empty, then display a default image, for example:

[wpv-conditional if="( '[wpv-post-featured-image output='url']' ne '' )"]
[wpv-post-featured-image]
[/wpv-conditional]

[wpv-conditional if="( '[wpv-post-featured-image output='url']' eq '' )"]
Your default image output here
[/wpv-conditional]

More help:
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-conditional

#1145156

My issue is resolved now. Thank you!

#1145320

You are welcome