If it’s only displayed on the top. (you don’t have to show it more then once on indivudual pages/posts). Then the following will work:
function dfi_skip_page ( $dfi_id, $post_id ) {
if ( is_singular() ) {
return 0; // invalid id
}
return $dfi_id; // the original featured image id
}
add_filter( 'dfi_thumbnail_id', 'dfi_skip_page', 10 , 2 );
I need it to display in all references to the post while not appearing within the post at the top.
I have other sections that are linking to these pages and I require them to have and image to be set to them, using featured image plays this role.
The plugin ‘Hide Featured image’ Allows me to turn this image off but your plugin is overriding it.
The code removed all trace of the image, meaning having the featured page selected effectively non-existent.
Define the function where ever you did.
But add the add_filter( 'dfi_thumbnail_id', 'dfi_skip_page', 10 , 2 );
Just above the place where you want to exclude the image. Below that add a remove_filter( 'dfi_thumbnail_id', 'dfi_skip_page', 10);
Rough example.
<header>
<!-- bla bla -->
<?php add_filter( 'dfi_thumbnail_id', 'dfi_skip_page', 10 , 2 ); ?>
<?php the_post_thumbnail() // will not show the default featured image ?>
<?php remove_filter( 'dfi_thumbnail_id', 'dfi_skip_page', 10); ?>
<!-- bla bla -->
</header>
<!-- bla bla -->
<?php the_post_thumbnail() // will show the featured image ?>
<!-- bla bla -->
Let me know how it goes.
Hi, Thanks for your time.
I looked back at what you previously stated and what you have suggested now.
I am fairly new to this so I was using the code wrong initially.
I have managed to work around my problem with what you have suggested.
I am using Enigma Pro and this provides a section to add custom code.
Here I inserted this section
function dfi_skip_page ( $dfi_id, $post_id ) {
if ( is_singular() ) {
return 0; // invalid id
}
return $dfi_id; // the original featured image id
}
add_filter( ‘dfi_thumbnail_id’, ‘dfi_skip_page’, 10 , 2 );
At the top of the page I needed to remove the image I then placed the following code.
<?php add_filter( ‘dfi_thumbnail_id’, ‘dfi_skip_page’, 10 , 2 ); ?>
Thank you very much for your help. Problem solved.
A tip. so it will be better to maintain.
Put the function definition in the theme functions.php
// source of this function: https://wordpress.org/support/topic/plugin-confliction-hide-featured-image
function dfi_skip_page ( $dfi_id, $post_id ) {
if ( is_singular() ) {
return 0; // invalid id
}
return $dfi_id; // the original featured image id
}
Only put the <?php add_filter( 'dfi_thumbnail_id', 'dfi_skip_page', 10 , 2 ); ?>
above the image.