Hello,
To achieve the output you are looking for, you can use the following code snippet:
add_filter( 'rank_math/frontend/show_keywords', function() {
return 'news keywords'; // Replace 'news keywords' with your desired keywords
});
By adding this code snippet to your theme’s functions.php
or rank-math.php
file, you will be able to display the "news keywords" meta tag on your website.
If you need further assistance or have any other questions, feel free to ask.
Sources:
How to Add Keywords to WordPress ยป Rank Math
How to Show Images in the Search Results ยป Rank Math
How to Remove Keywords Data from Article Schema ยป Rank Math
Rank Math SEO Filters and Hooks for Developers – Rank Math
Hello,
Thank you so much for getting in touch.
Please refer to this filter code instead:
add_action( 'rank_math/head', function() {
global $post;
$kws = get_post_meta($post->ID, 'rank_math_focus_keyword', true);
echo '<meta name="news keywords" content="'.$kws.'" />';
}, 99 );
You may refer to this guide on how to add filters to your website: https://rankmath.com/kb/wordpress-hooks-actions-filters/
Hope that helps.
can you make only post code
Hello,
If you only want to apply the code to the single posts, please use the following filter:
add_action( 'rank_math/head', function() {
global $post;
if(is_single()) {
$kws = get_post_meta($post->ID, 'rank_math_focus_keyword', true);
echo '<meta name="news keywords" content="'.$kws.'" />';
}
}, 99 );
Hope that helps and please do not hesitate to let us know if you need our assistance with anything else.
thank you
i have one more question
can’t i bring this news keyword under keyword
Hello,
That’s not possible. The custom tags will be added after the default tags of our plugin. However, the position of the meta tag doesn’t matter. As long as it is present in the page source and inside the head tag, Google will be able to read it.
Hope that helps and please do not hesitate to let us know if you need our assistance with anything else.
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/#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.