Add a default featured image to the media settings page. This featured image will show up if no featured image is set. Simple as that.
Take a look at FAQ for the basic questions.
Feel free to contact me on the forum or on the github repository.

توسط Jan-Willem
اگر با مشکلی مواجه شدهاید،
لطفاً آن را با جزئیات برای ما ارسال کنید.
🔒 برای ثبت گزارش خرابی باید وارد سایت شوید.
Add a default featured image to the media settings page. This featured image will show up if no featured image is set. Simple as that.
Take a look at FAQ for the basic questions.
Feel free to contact me on the forum or on the github repository.
/wp-content/plugins/ directoryThis plugin works out of the box for most cases, but not always. If it doesn’t work you can try the following things.
default-featured-img class added to them.Still having problems? I want to know if it fails, so contact me
There are no new functions, all core WordPress functions can be used.
Yes, the following code will set a different image.
add_filter( 'dfi_thumbnail_id', 'dfi_posttype_book', 10, 2 );
function dfi_posttype_book( $dfi_id, $post_id ) {
$post = get_post( $post_id );
if ( 'book' === $post->post_type ) {
return 31; // the image id for the book post type.
}
return $dfi_id; // the original featured image id.
}
Yes, the following snippet will set different images based on the category.
add_filter( 'dfi_thumbnail_id', 'dfi_category', 10, 2 );
function dfi_category( $dfi_id, $post_id ) {
// Set a different image for posts that have the 'cats' category set.
// This will trigger first, if multiple categories have been set.
if ( has_category( 'cats', $post_id ) ) {
return 7; // cats img id.
}
// Set a different image for posts that have the 'cats' category set.
if ( has_category( 'dogs', $post_id ) ) {
return 8; // dogs img id.
}
return $dfi_id; // the original featured image id.
}
When a Default Featured Image is used it will already add an extra class default-featured-img.
This can be used for styling.
If you need more you can change the whole HTML with the filter dfi_thumbnail_html.
add_filter( 'dfi_thumbnail_html', 'dfi_add_class', 10, 5 );
function dfi_add_class( $html, $post_id, $default_thumbnail_id, $size, $attr ) {
// Add a class to the existing class list.
$attr['class'] .= ' my-class';
return wp_get_attachment_image( $default_thumbnail_id, $size, false, $attr );
}
The following code will exclude the post/page with ID 23.
add_filter( 'dfi_thumbnail_id', 'dfi_skip_page', 10, 2 );
function dfi_skip_page( $dfi_id, $post_id ) {
if ( $post_id == 23 ) {
return 0; // invalid id.
}
return $dfi_id; // the original featured image id.
}
قیمت:
رایگان
نگارش
آخرین انتشار
10 اردیبهشت 1405
آخرین بروزرسانی
2 ماه پیش
نصب های فعال
70,000+
نگارش وردپرس
وردپرس 6.2+
تست شده از نسخه
وردپرس 6.9.4
نگارش PHP
PHP 7.4+
نسخه ها
0 نسخه