Hi I was wondering is it is possible to set a default featured image for a Custom Post type.
So basically a user can add a featured image, but if they forget the featured image will default to default-image.png
Thanks
Hello, thank you for contact us. I will try to do my best to help you.
If you have a custom post type and have a template for displaying single posts of that type, you would add it to the template (a Views Content Template, or a Template Layout if using Layouts).
Of if you have a View listing posts then this would go in the Loop Output section, either directly, or more likely in a content template that is linked to from the Loop Output section.
Although you are pasting in the code directly, you can insert the wpv-conditional shortcode using the conditional output button which appears on the relevant editors.
You need to use the wpv-conditional shortcode to test for the existence of the featured image, as described here: https://toolset.com/documentation/user-guides/conditional-html-output-in-views/checking-fields-and-other-elements-for-emptynon-empty-values/#checking-if-a-post-has-a-featured-image
So, you will add something like the following to your template:
[wpv-conditional if="( NOT(empty($(_thumbnail_id))) )"]
<div class="my_featured_image">
[wpv-post-featured-image size="full"]
</div>
[/wpv-conditional]
[wpv-conditional if="( empty($(_thumbnail_id)) )"]
<div class="no_featured_image">
// insert your alternative img tag here
</div>
[/wpv-conditional]
In another case, if you want to set a featured image for each post and you are not building custom vies or templates, you can use one of the plugins in the WordPress directory for that. For example, this one https://wordpress.org/plugins/default-featured-image/
Please let me know if this solves the issue or if you need further details.
Have a good day.