In the members-only forum a user asked:
Can you make a tutorial for setting a default featured image on a CPT in Genesis? For example, on a staff page when a staff member doesn’t have a profile picture available? To work in archives and single post.
By adding the following code in child theme's functions.php, we shall
- register custom image sizes for images on a Staff Custom Post Type archive and single pages.
- remove the featured image coming from Genesis settings (if set) and display left floating images (linking to their permalinks) on the Staff CPT archive. For entries with no featured image, a default image from the child theme's images directory will be set to appear.
- display image on Staff CPT single pages above the content. If a featured image is not present, a default image will appear.
Screenshots:
CPT archive page:
CPT single entry page when featured image is present:
CPT single entry page when featured image is not present:
To view the full content, please sign up for the membership.
Already a member? Log in below or here.
Thank you so much for this! I combined it with this https://sridharkatakam.com/staff-grid-genesis-clickable-featured-images-opening-excerpts-lightbox-popup/
How can we do it for posts archives, please, if a featured image isn’t set?