I am sending articles on wordpress through REST API, I want to add keywords.

#793499
  • Resolved Anonymous
    Rank Math free

    I am sending articles on wordpress through REST API, I want to add custom focus keywords along with each article. these keywords I want custom for each article. Is there any mehtod to add these focus keywords with wordpress REST API ?

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

    Thank you for reaching out with your question about adding custom focus keywords to articles sent through the WordPress REST API. To add custom focus keywords to each article using the WordPress REST API, you can utilize Rank Math’s automation feature to set focus keywords based on specific criteria.

    One way to achieve this is by using custom code snippets in your theme’s functions.php file or rank-math.php file. You can create a function that updates the focus keyword based on your custom criteria and then hook this function to the init action.

    Here is an example of how you can automatically update the focus keyword with custom keywords for each article:

    /**
     * Function to automatically update the focus keyword with custom keywords
     */
    function update_focus_keywords_custom() {
        // Replace this with your custom logic to fetch custom keywords for each article
        $custom_keywords = 'your_custom_keywords_here';
    
        // Update the focus keyword with the custom keywords
        update_post_meta(get_the_ID(), 'rank_math_focus_keyword', $custom_keywords);
    }
    add_action('init', 'update_focus_keywords_custom');

    By implementing a similar custom function tailored to your specific requirements, you can automate the insertion of custom focus keywords for each article sent through the WordPress REST API.

    If you need further assistance or have more questions, feel free to provide additional details or reply to this ticket. Our support team is here to help you.

    Looking forward to assisting you further!

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

    Anonymous
    Rank Math free

    How to set the custom keywords now in WordPress REST API? what is parameter name in payload?
    I am sending below payload on wordpress endpoint: https://site_name.com/wp-json/wp/v2/posts

    data = {
    ‘title’: title,
    ‘content’: content,
    ‘status’: ‘publish’,
    ‘categories’: [category_id],
    ‘featured_media’ : media_id,
    ‘excerpt’: custom python code to create excerpt from article
    }

    how to pass custom keyrankmath focus keywords with it

    Hello,

    Here are the meta keys to add the metadata using the API:

    rank_math_title
    rank_math_description
    rank_math_focus_keyword

    Please make sure that the meta keys are registered inside the postmeta table.

    You can learn how to register the meta key in this example here: https://wordpress.stackexchange.com/questions/380513/add-post-meta-fields-when-creating-a-post-using-wordpress-rest-api

    Hope that helps.

    Anonymous
    Rank Math free

    Hello, I am not familiar with PHP coding and this page you provided have too much code and there is no clear mention which function to use?

    can you please help me or provide me the exact code to add these meta keys to use along with wordpress REST API

    Please help

    Anonymous
    Rank Math free

    is anyone here to help? can you provide me clear guide how to add these meta keys?

    Hello,

    Custom coding is outside the scope of our support so if you want to do this programmatically and don’t have the required knowledge in terms of PHP coding you would need to hire someone to perform this for you.

    We already shared the metadata that is used by our plugin and how to register that. Beyond that, custom code to extend functionalities like this is not possible at the moment.

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

The ticket ‘I am sending articles on wordpress through REST API, I want to add keywords.’ is closed to new replies.