I want to Programmatically update rank math title using custom feild

#397448
  • Resolved Noor Shaad
    Rank Math free

    Hi there, programmatically I want to Programmatically update rank math title using custom feild. I don’t know which field is this on wordpress post. Can you guide me with this ?

    add_post_meta($post_id, ‘rankmath custom title field’, $mytitle );

Viewing 5 replies - 1 through 5 (of 5 total)
  • I tried this code.
    add_post_meta($post_id ,’rank_math_title’, $mcptitle);
    but it’s not updating or set the rank math title. what’s the problem ? can anyone help me please?

    Prabhat
    Rank Math agency

    Hello,

    Thank you for contacting the support.

    The add_post_meta() function adds a new meta key for the given post ID and does not update the existing one. If the named key already exists, a duplicate field is created.

    To update an existing field, you can use the update_post_meta() function: https://developer.wordpress.org/reference/functions/update_post_meta/

    However, if you only want to use the data of a custom field in SEO Title, you can simply use this variable in the SEO title field: https://rankmath.com/kb/variables-in-seo-title-description/#num-39-custom-field-advanced

    Hope this helps.

    Thank you.

    I try this add_post_meta() function for adds a new post meta field. But It’s not setting. I tried this same code on old rank math it’s worked. Currently I want to use it on latest version of rank math.

    Even I can’t add it from wordpress post dashboard. https://prnt.sc/MQBDhRlKeO7o

    Hello,

    As explained previously by my colleague, the add_post_meta() function doesn’t modify our existing post meta for the title. You can make use of this variable instead and insert it into Rank Math’s title meta:

    %customfield(YOUR_FIELD_NAME)%

    test

    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 ‘I want to Programmatically update rank math title using custom feild’ is closed to new replies.