ضع هذا الكود في ملف functions.php
\[code\]function sb\_autoset\_featured()
{
global $post;
$already\_has\_thumb = has\_post\_thumbnail($post->ID);
if (!$already\_has\_thumb) {
$attached\_image = get\_children(
array(
'numberposts' => '1',
'post\_parent' => $post->ID,
'post\_type' => 'attachment',
'post\_mime\_type' => 'image',
)
);
if ($attached\_image) {
foreach ($attached\_image as $attachment\_id => $attachment) {
set\_post\_thumbnail($post->ID, $attachment\_id);
}
} else {
set\_post\_thumbnail($post->ID, '1638');
}
}
}
add\_action('the\_post', 'sb\_autoset\_featured');
add\_action('save\_post', 'sb\_autoset\_featured');
add\_action('draft\_to\_publish', 'sb\_autoset\_featured');
add\_action('new\_to\_publish', 'sb\_autoset\_featured');
add\_action('pending\_to\_publish', 'sb\_autoset\_featured');
add\_action('future\_to\_publish', 'sb\_autoset\_featured');\[/code\]
لا تنس قم بإستبدالرقم 1638 (السطر 11) بالرقم المعرف (ID) الخاص بالصورة التي تريد أن تكون كصورة بارزة إفتراضية للمقالات التي لا تحتوي على أي صورة.