Inquiry about focus keyword

#66621
  • Resolved MSOW LTD
    Rank Math free

    Hi.

    Is it possible to setup Rank Math to autofill focus keyword by product title?

    Looking forward to your reply
    Ioannis

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hello,

    Thank you for contacting Rank Math today.

    Unfortunately there is no current feature in Rank math to do so. You can use the following snippet that was used to auto-fill the keyword using tags. With the help of a developer, you can customize it to fit your situation.

    
    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){
    		if(get_the_tags($p->ID)){
    			foreach((get_the_tags($p->ID)) as $tag) {
                    $keywords[] = strtolower($tag->name);
                }
    		update_post_meta($p->ID,'rank_math_focus_keyword',implode(", ", array_unique($keywords)));
    		}
    	}
        
    }
    add_action( 'init', 'update_focus_keywords' );
    

    Hope it helps you. Thank you.

    ​​​​​​

    Hi,

    When I run that script everything crashes.
    I guess it because I have more than 18000 posts.

    Is there any SQL command I can use instead?

    Thank you

    Hello,

    You marked this as resolved, were you able to find a solution?

    Looking forward to helping you. Thank you.

    ​​​​​​

    Hey Michael

    Yes i modified your snippet and is working fine.

    Thank you

    Alberto
    Rank Math business

    Hello,

    We are super happy that this resolved your issue. If you have any other questions in the future, know that we are here to help you.

    If you don’t mind me asking, could you please leave us a review (if you haven’t already) on https://wordpress.org/support/plugin/seo-by-rank-math/reviews/#new-post about your overall experience with Rank Math? We appreciate your time and patience.

    If you do have another question in the future, please feel free to create a new forum topic, and it will be our pleasure to assist you again.

    Thank you.

Viewing 5 replies - 1 through 5 (of 5 total)

You must be logged in to reply to this ticket.