RakipsizHizmet adlı üyeden alıntı: mesajı görüntüle
functions.php dosyasına veya aktif kullandığınız temanın içine rank-math.php adında bir dosya oluşturun. Aşağıdaki seçime göre kodu bu dosyanın içerisine ekle.
Tüm sitedeki yazılar için gönderi başlığının anahtar kelime olmasını istiyorsanız:
/**
 * Function to automatically update the focus keyword with the post title
 */
function update_focus_keywords()
{
    $posts = get_posts(array(
        'posts_per_page'    => -1,
        'post_type'        => 'post' //replace post with the name of your post type
    ));
    foreach ($posts as $p) {
        update_post_meta($p->ID, 'rank_math_focus_keyword', strtolower(get_the_title($p->ID)));
    }
}
add_action('init', 'update_focus_keywords');
Yada sadece odak anahtar kelimesi olmayan yazılar için gönderi başlığını odak anahtar kelime yapmak istersen:
/**
 * Function to automatically update the focus keyword with the post title, if no focus keyword is set
 */
function update_focus_keywords() {
    $posts = get_posts(array(
    'posts_per_page'    => -1,
    'post_type'        => 'post' // Replace post with the name of your post type
    ));
    foreach($posts as $p){
        // Checks if Rank Math keyword already exists and only updates if it doesn't have it
        $rank_math_keyword = get_post_meta( $p->ID, 'rank_math_focus_keyword', true );
    if ( ! $rank_math_keyword ){
            update_post_meta($p->ID,'rank_math_focus_keyword',strtolower(get_the_title($p->ID)));
        }
    }
}
add_action( 'init', 'update_focus_keywords' );
Merhaba hocam ilginiz için teşekkür ederim. Peki ben belirlediğim anahtar kelimeleri girmek istiyorum başlık değil de bunu yapabiliyor muyuz? Bunu denedim sorunsuz bütün içeriklerin anahtar kelimeleri başlıkta ki gibi oldu