Is there a way to prevent the featured image from even showing up in a post’s gallery?
e.g. when editing the gallery in the admin for a post, the featured image isn’t there.
Is there a way to prevent the featured image from even showing up in a post’s gallery?
e.g. when editing the gallery in the admin for a post, the featured image isn’t there.
You must be logged in to post a comment.
Okay, I had the same problem and just solved it by adding an “exclude” field to the shortcode. Like so…
You have to just pull the ID number of the file you don’t want to show. This works without adding any functions or edits to the theme.
I am agree with @janw’s answer.
I would like to add further as:
You can edit your single template to automatically show the gallery without needing to insert the gallery shortcode manually.
Open your single.php file and inside the loop, where you want the gallery to be displayed, copy this line of code:
If you use the
gallery
shortcode you can add theexclude
param with the id of the featured image to exclude it.If you want to do it dynamically I suggest using the
post_gallery
filter.not tested but should work.