Automatically Use the EDD Download Title as the Focus Keyword

#478572
  • Resolved ali kavyani
    Rank Math free

    Hi RankMath support,

    Based on this article I tried to automate the Insertion of Focus Keyword for EDD Products.

    https://rankmath.com/kb/how-to-automate-the-insertion-of-focus-keyword/

    First, I created the rank-math.php at the theme folder.

    Then I added this code to it.

    <?php
    /**
    * Function to automatically update the focus keyword with the post tags, if no focus keyword is set
    */
    function update_focus_keywords()
    {
    $posts = get_posts(array(
    'posts_per_page' => 100,
    'post_type' => 'download' //replace post with the name of your post type
    ));
    foreach ($posts as $p) {
    $keywords = [];
    if (get_the_tags($p->ID)) {
    foreach ((get_the_tags($p->ID)) as $tag) {
    $keywords[] = strtolower($tag->name);
    }
    if (!get_post_meta($p->ID, 'rank_math_focus_keyword', true)) {
    update_post_meta($p->ID, 'rank_math_focus_keyword', implode(", ", array_unique($keywords)));
    }
    }
    }
    }
    add_action('init', 'update_focus_keywords');

    ?>

    But after the download update, the keyword is not updated.

    ———————————————————————–

    And one more question:

    is there anyway to add KKstar ratings to EDD product schema in rank math?

    Can you help me?

Viewing 1 replies (of 1 total)
  • Hello,

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

    Checking the code you shared, it seems to be working after we tested it in our local install. Can you please enable your website’s debugging mode and check for any error logs?

    As for the ratings, you can get in touch with the developer of the KK Star rating plugin and ask them to implement their aggregateRating Schema with Rank Math’s Schema using the following filter: https://rankmath.com/kb/filters-hooks-api-developer/#extend-json-ld-data

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

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