Small issue with focus keyword

#725662
  • Resolved Anonymous
    Rank Math free

    Hey, I’m developer and few of my sites affected the same issue I want to share with you.

    I’m generating focus keywords for posts using ChatGPT API. For some reason API returns empty array instead of keywords separated by comma. And if I store empty array using update_post_meta($post_id, ‘rank_math_focus_keyword’, $empty_array); I get 500 error here /wp-admin/edit.php.

    Right now I fixed my issue but my proposal is the following. Could you handle this case somehow so no error will appear?

    Thanks a lot, really love your product 🙂

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

    I’m sorry to hear about the issue you encountered with generating focus keywords using the ChatGPT API. It’s great to hear that you were able to fix the issue on your end.

    Regarding your proposal, we appreciate your feedback and will definitely consider handling this case to prevent any errors from occurring in the future. If you encounter any similar issues or have further suggestions, please feel free to reach out to our support team by assigning this ticket to us using the available buttons.

    Thank you for your kind words and for using Rank Math! If you have any other questions or need further assistance, please don’t hesitate to let us know.

    Kind regards.

    Sources:
    How to Automate the Insertion of Focus Keyword » Rank Math

    Anonymous
    Rank Math free
    public function get_focus_keyword()
        {
            $keywords = '';
            if (! empty($this->args->ID)) {
                $keywords = get_post_meta($this->args->ID, 'rank_math_focus_keyword', true);
            }
    
            if (! empty($this->args->term_id)) {
                $keywords = get_term_meta($this->args->term_id, 'rank_math_focus_keyword', true);
            }
    
            $keywords = explode(',', $keywords);
            if ('' !== $keywords[0]) {
                return $keywords[0];
            }
    
            return null;
        }

    Will be perfect to get any checks before you’re exploding $keywords varialbe.

    Hello,

    Thank you so much for getting in touch.

    We tested the code from our end with a working post object and it seems the code you have presented is working without any issues. I have tested this using posts with a single focus keyword and multiple ones as well.

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

    Anonymous
    Rank Math free

    Hello,

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

    Thank you.

    Hello,

    The rank_math_focus_keyword meta key stores values as a string, not an array. That’s why the update meta function is returning an error. You should use update_post_meta(1, 'rank_math_focus_keyword', ''); to fix the issue.

    I hope that helps, and please do not hesitate to let us know if you need our assistance with anything else.

    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 ‘Small issue with focus keyword’ is closed to new replies.