aşağıdaki kodu kopyalayıp resim.php olarak kaydedin.
daha sonra resim.php dosyasını wp ana klasörünüze yükleyin (wp-config.php ile aynı dizin)
sitenizinadi.uzanti/resim.php olarak web sayfasında linke gidin. postlardaki ilk resmi öne çıkan görsel olarak ayarlar
Not: resimler yazılarda atachlı olmak zorunda url veya html blok içerisindeki resimleri almaz
<?php
// r10.net/iskendercnr
require __DIR__ . '/wp-load.php';
$args = array(
'post_type' => 'post',
'posts_per_page' => -1,
);
$posts = get_posts($args);
foreach ($posts as $post) {
$post_id = $post->ID;
$attachments = get_posts(array(
'post_type' => 'attachment',
'posts_per_page' => -1,
'post_parent' => $post_id,
));
if ($attachments) {
set_post_thumbnail($post_id, $attachments[0]->ID);
}
}
?>