How to setup RankMath SEO focus keyword, meta description using rest api

#602673
  • Resolved Anonymous
    Rank Math free

    Hi,
    I am creating and updating my woocommerce product using wc rest API
    All fields creating and updating the product correctly
    But it not showing the fields _math_rank_seo_focus_keyword, _math_rank_seo_title, _math_rank_seo_description.

    for doing this write this sample code:

    
    from woocommerce import API
    from pprint import pprint
    import requests
    import json
    
    wcapi = API(
        url="https://mysite.com/",
        consumer_key="ck_****************************************",
        consumer_secret="cs_************************************",
        wp_api=True,
        version="wc/v3",
        query_string_auth=True
    )
    
    data = {
        # "name": "",
        # # "regular_price": "<new-regular-price>",
        # "description": "",
        # "short_description": "",
        "meta_data": [
            {"key": "_math_rank_seo_focus_keyword", "value": "your keyword"},
            {"key": "_math_rank_seo_title", "value": "your seo title"},
            {"key": "_math_rank_seo_description", "value": "your seo description"},
        ],
        # "slug": "new-product-url"  # new url
    
    }
    
    response = wcapi.put("products/50244", data)
    pprint(response.json())
    

    in the API response I found this:

    
    .
    .
    .
    .
    .
    
     'meta_data': [
                   {'id': 65182,
                    'key': '_math_rank_seo_focus_keyword',
                    'value': 'your keyword'},
                   {'id': 65183,
                    'key': '_math_rank_seo_description',
                    'value': 'your seo description'},
                   {'id': 65185, 'key': 'rank_math_seo_score', 'value': '19'},
                   {'id': 65186, 'key': '_rank_math_gtin_code', 'value': ''},
                   {'id': 65205,
                    'key': '_math_rank_seo_title',
                    'value': 'your seo title'}],
    .
    .
    .
    .
    .
    

    but when I go to edit option in the product I could not see any any text on those field _math_rank_seo_focus_keyword, _math_rank_seo_title, _math_rank_seo_description

    I see this ticket https://support.rankmath.com/ticket/how-to-setup-seo-title-using-wordpress-rest-api/
    and I make the function to similar to this see the screenshot https://prnt.sc/12_CMLIxmkw7

    Now please tell me how can solve this issue.

Viewing 1 replies (of 1 total)
  • Hello,

    Thank you for contacting Rank Math and bringing your concern to our attention. I’m sorry for any inconvenience this issue may have caused you.

    The fields you have shared are _math_rank_ instead of rank_math_.

    Please update it to these values to match the correct data:

    data = {
        'meta': {
            'rank_math_title': 'My Title',
            'rank_math_description': 'My Description'
        }
    }

    Hope that helps.

    Thank 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 ‘How to setup RankMath SEO focus keyword, meta description using rest api’ is closed to new replies.