mustafabosnak adlı üyeden alıntı: mesajı görüntüle
Fonksiyon daha önce oluşturulduğu içinde olabilir farklı bir isim verip deneyebilir misiniz hocam?
[COLOR=#515365][FONT=consolas]function update_focus_keywords2() {[/FONT][/COLOR]
[COLOR=#515365][FONT=consolas]    $posts = get_posts(array([/FONT][/COLOR]
[COLOR=#515365][FONT=consolas]    'posts_per_page'    => -1,[/FONT][/COLOR]
[COLOR=#515365][FONT=consolas]    'post_type'        => 'post' // Replace post with the name of your post type[/FONT][/COLOR]
[COLOR=#515365][FONT=consolas]    ));[/FONT][/COLOR]
[COLOR=#515365][FONT=consolas]    foreach($posts as $p){[/FONT][/COLOR]
[COLOR=#515365][FONT=consolas]        // Checks if Rank Math keyword already exists and only updates if it doesn't have it[/FONT][/COLOR]
[COLOR=#515365][FONT=consolas]        $rank_math_keyword = get_post_meta( $p->ID, 'rank_math_focus_keyword', true );[/FONT][/COLOR]
[COLOR=#515365][FONT=consolas]    if ( ! $rank_math_keyword ){[/FONT][/COLOR]
[COLOR=#515365][FONT=consolas]            update_post_meta($p->ID,'rank_math_focus_keyword',strtolower(get_the_title($p->ID)));[/FONT][/COLOR]
[COLOR=#515365][FONT=consolas]        }[/FONT][/COLOR]
[COLOR=#515365][FONT=consolas]    }[/FONT][/COLOR]
[COLOR=#515365][FONT=consolas]}[/FONT][/COLOR]
[COLOR=#515365][FONT=consolas]add_action( 'init', 'update_focus_keywords2' );[/FONT][/COLOR]
gibi.
emrenogay adlı üyeden alıntı: mesajı görüntüle
Test sitemde denedim bir sorun yok kodda. Sanırım tahmin ettiğim gibi autoload olmuyor. Kodu functions.php'de deneyin.
Tahmin ettiğim gibi kodu eklediğim satır yanlışmış. Kodu görseldeki gibi en üst satıra eklediğimde sorunsuz çalıştı.