Hello,
Thank you for contacting Rank Math and sorry for any inconvenience that might have been caused due to that.
Your code should be able to work. Could you please debug the output from your $post_id variable to check if it is returning the expected data?
Please note that you can also hook into the following filter with slightly different logic and assign keywords to your posts:
/**
* Allow changing the meta keywords from the default Focus Keywords.
*
* @param string $keywords Keywords.
*/
add_filter( 'rank_math/frontend/keywords', function( $keywords ) {
return $keywords;
});
Looking forward to helping you. Thank you.
Hi,
The problem was with the variable value I was using as keyword. Sorted.
Thank you
Hello,
We are super happy that this resolved your issue. If you have any other questions in the future, know that we are here to help you.
If you don’t mind me asking, could you please leave us a review (if you haven’t already) on https://wordpress.org/support/plugin/seo-by-rank-math/reviews/?rate=5#new-post about your overall experience with Rank Math? We appreciate your time and patience.
If you do have another question in the future, please feel free to create a new forum topic, and it will be our pleasure to assist you again.
Thank you.