Hello,
I’m sorry for the inconvenience, but it’s not possible to noindex users who don’t have any posts directly. Noindexing is typically done at the post or page level to prevent them from being indexed by search engines. If you have any other questions or need further assistance, please feel free to ask.
Thank you for reaching out to us!
Sources:
How to Noindex URLs With Rank Math » Rank Math
Advanced Tab in Rank Math SEO’s Meta Box
How to NoIndex All Posts in a Category » Rank Math
Fix Excluded by NoIndex Tag – Google Search Console Status » Rank Math
How to Fix Submitted URL Marked ‘NoIndex’ Error » Rank Math
any custom code for do this?
Hello,
Assuming you have already set your author meta to index in Rank Math > Titles & Meta > Author > Author Robots Meta, you can use and customize this filter to set your authors to noindex if they don’t have any posts published :
add_filter( 'rank_math/frontend/robots', function( $robots ) {
$author = get_the_author_meta('ID');
$user_id = get_current_user_id($author); //the logged in user's id
$post_type = 'post';
$posts = count_user_posts( $user_id, $post_type ); //count user's posts
if( $posts < 0 ){
$robots["index"] = 'noindex';
$robots["follow"] = 'nofollow';
}
return $robots;
});
If you’re not sure how to add this code, you can follow this guide:
https://rankmath.com/kb/wordpress-hooks-actions-filters/
Let us know how this goes.
Hi Reinelle,
Thank you so much!
I’ve added this on child the function.php. How can I check if it work or not?
Hello,
You can check the ‘source’ page of the user’s URL view-source:https://yourwebsite.com/author/username/
and check if it is set to noindex. Replace ‘yourwebsite’ and ‘username’ with the correct info.
When you check, the content
should be set to noindex
An example is shown in the image below:
Hope this helps, and please do not hesitate to let us know if you need our assistance with anything else.
Thank you for choosing Rank Math.
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.