CPT title bulk focus keyword

#380868
  • Hi Rankmath,

    Is it possible to choose a specific CPT and use the following code:

    /**
    * 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’);

    Cause I only want it applied to all titles in a specific CPT

    Best regards
    Jacob

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

    It seems that you already marked this ticket as β€œResolved”.

    Do you still need our assistance regarding this issue?

    Looking forward to helping you.

    Thank you.

    Hi!

    Yeah, I could use your help 😊 I did the script in a CPT called “acapellas”, and it changed the focus keyword to the title, which was nice. Now my only problem is that it seems like Rankmath doesn’t recognize that it is the same as the title. So I still need to go into my +1000 posts and re-do for some reason in order for it to be marked green in the “basic seo improvements”

    Can you help me out? πŸ˜…

    Hello,

    The code that you have shared should automatically insert a focus keyword same as the post’s title. Can you please confirm if that wasn’t the case from your end?

    I have marked this ticket “Not resolved” for us to ask for further information about the issue if the issue persists.

    Looking forward to helping you on this one.

    I did insert the focus keyword from the post title, but the “basic seo improvements” doesn’t recognize these as equal. It still says that I could improve by using the same focus keyword in the title πŸ˜…

    Hello,

    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.

    Hello,

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

    Thank you.

    Hello,

    I noticed that there has been a mismatch if you are using a different type of single quote in the keyword. Please refer to my video screencast below to see what I mean:

    https://i.rankmath.com/lCSAhg

    Allow me to share this with our developers and check what might be the issue here. We should get back to you shortly.

    Looking forward to helping you on this one.

    Thanks, but that doesnt make any sense since it should take it from the title itself with the script you provided πŸ˜…

    Hello,

    This issue is caused by the same situation that our developers mentioned in the other ticket you have.

    This encoding issue is what’s causing the focus keyword to seem different from the title and thus the tests are failing for that.

    Don’t hesitate to get in touch if you have any other questions.

    But how do I fix this encoding issue so it matches? πŸ˜…

    Hello,

    We use the default UTF-8 encoding and don’t perform anything else to encode or decode to a different charset.

    You can get in touch with your hosting provider and ask them about this situation and what exactly is the encoding you have on your database and the collation of the tables.

    If they don’t match with the current Rank Math specification that could cause these issues.

    Don’t hesitate to get in touch if you have any other 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 11 replies - 1 through 11 (of 11 total)

The ticket ‘CPT title bulk focus keyword’ is closed to new replies.