Hi yorgosgk
That’s unfortunate to hear. You have a theme which support featured images. How rare. The fix is easy enough:
Create a file wp-content/plugins/dfi-exclude-nav.php
and put the following code inside:
<?php
/**
* Plugin Name: Default Featured Image, exclude navigation items.
* Plugin URI: https://wordpress.org/support/topic/default-image-also-showing-on-my-nav-bar/
* Version: 1.0
*/
function dfi_exclude_nav ( $dfi_id, $post_id ) {
$post = get_post($post_id);
if ( 'nav_menu_item' === $post->post_type ) {
return 0; // Don't use DFI for this posttype
}
return $dfi_id; // the original featured image id
}
add_filter( 'dfi_thumbnail_id', 'dfi_exclude_nav', 10, 2 );
And activate this plugin in WordPress.
Let me know how it goes
Jan-Willem
Wow, that was unbelievable response time THANKS A LOT! UNFORTUNATALY though 🙁
Didn’t work!
https://prnt.sc/v3vi3x
http://prntscr.com/v3vgxk
they are still there….
this is in my php file exactly that i uploaded http://prntscr.com/v3vina
For what its worth – here is the inspector https://prnt.sc/v3vjok
Sorry, I posted the wrong code. (of another question)
I’ve updated the code in the post above.
Can you try it?
Jan-Willem
WORKED!
Really quick question now, if I wanted a default image that’s category specific does this code affect the code you have in the support documentation and in other threads here.?
Sorry I didn’t see your reply.
You can combine and mix them. But some might screw with others.
It probably should work if you give them the correct order.
But making 1 filter that handles all would probably be nicer.
implementing a category check would be:
<?php
/**
* Plugin Name: Default Featured Image, exclude navigation items.
* Plugin URI: https://wordpress.org/support/topic/default-image-also-showing-on-my-nav-bar/
* Version: 1.0
*/
function dfi_exclude_nav( $dfi_id, $post_id ) {
$post = get_post( $post_id );
if ( 'nav_menu_item' === $post->post_type ) {
return 0; // Don't use DFI for this posttype
}
// all which have 'animals' as a category
if ( has_category( 'animals', $post_id ) ) {
//sub category
if ( has_category( 'cats', $post_id ) ) {
return 7; // cats img
} else if ( has_category( 'dogs', $post_id ) ) {
return 8; // dogs img
}
return 6; // default animals picture
}
return $dfi_id; // the original featured image id
}
add_filter( 'dfi_thumbnail_id', 'dfi_exclude_nav', 10, 2 );
Let me know how it goes