Automatically Use the Post Title as the Focus Keyword

#255862
Viewing 3 replies - 1 through 3 (of 3 total)
  • Anas
    Rank Math business

    Hello,

    Thank you for contacting Rank Math.

    If you want to add the focus keywords to the product, change the post type to “product”.

    function update_focus_keywords() {
    	$posts = get_posts(array(
    	'posts_per_page'	=> -1,
    	'post_type'		=> 'product' //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' );

    After adding the code, clear the website cache and check again.

    I hope this helps. Looking forward to helping you.

    Thank you so much, it worked.

    Anas
    Rank Math business

    Hello,

    We are super happy that your issue is resolved. 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 3 replies - 1 through 3 (of 3 total)

The ticket ‘Automatically Use the Post Title as the Focus Keyword’ is closed to new replies.