convert tags into keywords

#40901
  • Resolved Michal Rudolf
    Rank Math free

    Hello,

    is there a way how to mass convert tags into post keywords?

    I have 500plus posts with proper tags and i do not want to copy them manually.

    Thanks
    Michal

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

    Thank you for contacting Rank Math today.

    Unfortunately, we don’t have that option yet. You can try using the code snippet here :Use Categories and Tags as Keywords

    Hope this helps you. Thank you.

    ​​​​​​

    Thank you.

    But I nean keywords that are set in Rank Math.

    Thanks
    Michal

    Hi Michal,

    Thanks for the follow up.

    This would require a custom code snippet to populate the focus keywords from the tags assigned to the page. Here is an example snippet that you can add to your theme’s functions.php file to loop through your posts and update the focus keyword:

    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' );

    You would need to delete this code after the keywords have been updated. Please perform a backup before using this code since it will replace the keywords assigned to posts.

    I hope this info helps. Thank you.

    Iam sorry, but it does not work, it added one same keyword to all posts.

    Hi Michal,

    Thanks for the follow up.

    I had already tested the snippet on my end and it seems to work.

    We might need to take a closer look at the settings. Please edit the first post on this ticket and include your WP logins in the designated Sensitive Data section.
    Sensitive Data Section

    It is completely secure and only our support staff has access to that section. If you want, you can use the below plugin to generate a temporary login URL to your website and share that with us instead:

    https://wordpress.org/plugins/temporary-login-without-password/

    You can use the above plugin in conjunction with the WP Security Audit Log to monitor what changes our staff might make on your website (if any):

    https://wordpress.org/plugins/wp-security-audit-log/

    We really look forward to helping you.

    Hello,

    Since we did not hear back from you for 15 days, we are assuming that you found the solution. We are closing this support ticket.

    If you still need assistance or any other help, please feel free to open a new support ticket, and we will be more than happy to assist.

    Thank you.

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

The ticket ‘convert tags into keywords’ is closed to new replies.