Update RankMath Meta Title, Meta Description and Focus Keyword using jQuery

#621205
  • Resolved Anonymous
    Rank Math free

    Hello,

    I am using GPT AI to automate the process to generate and update Update Meta Title, Meta Description and Focus Keyword. On post edit page, I have added a button “Generate Snippet” in Rankmath metabox (beside the edit snippet button”. When clicking on this button, it receives response from gpt api and then i am trying to update it in rankmath fields. For eg:-
    jQuery(‘textarea#rank-math-editor-description’).val(jQuery.trim(obj.chatgpt_response.meta_description));
    jQuery(‘textarea#rank-math-editor-description’).trigger(‘keyup’);

    I have also tried updating the rankmath json data s below:-
    rankMath.assessor.serpData.title=jQuery.trim(obj.chatgpt_response.meta_title);

    I have also tried various simulation technique to simulate user input But nothing is working. Can you suggest me a solution for this.

    However, there are some kind of jugaad which i can do, for example saving the values in hidden input and update rank math meta_key value on save_post hook. But i don’t want to do this since the first approach is more realistic.

    Awaiting your response.

    Thank You,
    Sharique Anwer

Viewing 1 replies (of 1 total)
  • Hello,

    Thank you so much for getting in touch.

    What you are trying to achieve is not feasible since the entire Rank Math SEO Metabox is based on React which is a JS framework and you are trying to access its data and update it using a different JS library.

    The only viable solution would be the second one you mentioned about adding the data to custom fields and then hooking a function in the save_post action to update the metadata using the relevant custom fields.

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

The ticket ‘Update RankMath Meta Title, Meta Description and Focus Keyword using jQuery’ is closed to new replies.