adding focus keywords snippet

#396110
  • Resolved Ghers
    Rank Math pro
    Content AI Starter

    added the “focus keywords”snippet in snippets but its not added the focus keywords to a page

Viewing 8 replies - 1 through 8 (of 8 total)
  • Ghers
    Rank Math pro
    Content AI Starter

    I added the snippet on you site for focus Keywords to a external snippet plugin snippets, but noting happens on a new site or when remove the focus keywords

    Hello,

    Thank you for contacting Rank Math and sorry for any inconvenience that might have been caused due to that.

    Could you please share the full code that you have added to your website to automate the insertion of focus keywords?

    ​​​​​​​Also, please share a screenshot from the backend of the pages without a focus keyword so we can advise further.

    Looking forward to helping you.

    Ghers
    Rank Math pro
    Content AI Starter

    /**
    * Function to automatically update the focus keyword with the post title, if no focus keyword is set
    */
    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){
    // Checks if Rank Math keyword already exists and only updates if it doesn’t have it
    $rank_math_keyword = get_post_meta( $p->ID, ‘rank_math_focus_keyword’, true );
    if ( ! $rank_math_keyword ){
    update_post_meta($p->ID,’rank_math_focus_keyword’,strtolower(get_the_title($p->ID)));
    }
    }
    }
    add_action( ‘init’, ‘update_focus_keywords’ );

    Hello,

    The code you shared should work on your posts.

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

    Please do take a complete backup of your website before sharing the information with us.
    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.

    Ghers
    Rank Math pro
    Content AI Starter

    Hello,

    I have updated the sensitive data as requested. Can you please check further?

    Thank you.

    Hello,

    Please also share the login URL of your site so we can check and assist you further.

    Looking forward to helping you.

    Ghers
    Rank Math pro
    Content AI Starter

    Hello,

    I have updated the sensitive data as requested. Can you please check further?

    Thank you.

    Nigel
    Rank Math business

    Hello,

    I checked the code snippet on your website and it was set to work for ‘posts’ only. I changed it to work for “pages” as they are the main content type on your website. Screenshot:

    Hope that helps. Please let us know if you have questions.

    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 8 replies - 1 through 8 (of 8 total)

The ticket ‘adding focus keywords snippet’ is closed to new replies.