Yazılara otomatik anahtar kelime girsin diye eklediğim kod cpu tüketiyor, 10 çekirdek sunucu bile dayanmıyor direkt siteyi kitliyor.
Bu kodu 1 ay önce paylasmıstım faydalı oldugu icin ama ben kullanamıyorum maalesef:
/** * 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');
Sorunsuz çalışıyor
@CanYildirim; teşekkürler
[COLOR=#D9DAE9][FONT=consolas]function update_focus_keywords() {[/FONT][/COLOR]
[COLOR=#D9DAE9][FONT=consolas] $posts = get_posts(array([/FONT][/COLOR]
[COLOR=#D9DAE9][FONT=consolas] 'posts_per_page' => 100,[/FONT][/COLOR]
[COLOR=#D9DAE9][FONT=consolas] 'post_type' => 'post'[/FONT][/COLOR]
[COLOR=#D9DAE9][FONT=consolas] ));[/FONT][/COLOR]
[COLOR=#D9DAE9][FONT=consolas] foreach($posts as $p){[/FONT][/COLOR]
[COLOR=#D9DAE9][FONT=consolas] if(!get_post_meta($p->ID, 'rank_math_focus_keyword', true)){[/FONT][/COLOR]
[COLOR=#D9DAE9][FONT=consolas] update_post_meta($p->ID,'rank_math_focus_keyword', $p->post_title);[/FONT][/COLOR]
[COLOR=#D9DAE9][FONT=consolas] }[/FONT][/COLOR]
[COLOR=#D9DAE9][FONT=consolas] } [/FONT][/COLOR]
[COLOR=#D9DAE9][FONT=consolas]}[/FONT][/COLOR]
[COLOR=#D9DAE9][FONT=consolas]add_action( 'init', 'update_focus_keywords' );[/FONT][/COLOR]