Archived topic
Remove Featured Image On Certain Posts - Dispatch Demo
5 replies · Started by Blair on November 3, 2021
I have read through many of the topics on this and still can't get the settings correct.
I want to be able to show the Dispatch featured image on certain posts, but from the individual page settings, not the global element.
I am rebuilding my site and imported 100+ posts, but my featured image is not sized correctly. I want to hide the featured image on those and going forward use the correct size image.
Also, some posts don't need a featured image on page. I know I can disable them in the element settings, but that is global.
Is there a way to do it page by page depending on the content I have?
Hi there,
whats the ultimate goal here? Is it to remove the Hero Element on the site ? But one at a time and display the default featured image instead ?
I want to use the hero image that Dispatch has with out the meta data ( author / date / category), just title on all some new posts going forward. Some articles a hero image doesn't make sense and I want to have fast LCP in google page speeds.
I will be going back and adding in new featured images that are sized correctly for old posts.
Right now the on page meta box inside the editor, when I turn off featured image, it doesn't hide the Dispatch Hero Image. If I disable the hero image global, I can hide / unhide the standard featured image.
THANK YOU!!!!
Try adding this PHP Snippet:
add_filter( 'generate_element_display', function( $display, $element_id ) {
if ( 123 === $element_id ) { // Only target specific Element
if ( has_post_thumbnail() && get_post_meta( get_the_ID(), '_generate-disable-post-image', true ) === 'true' ) {
$display = false;
}
}
return $display;
}, 10, 2 );
In this part of the code: 123 === $element_id you need to change the 123 to the ID of the Element. You can find the ID by editing the Element, and checking the URL in the browser.
This will disable that Element if the post has a featured image and the Disable Featured Image option is selected.
Thanks, will do
You're welcome