-
Hi there,
I would like to “noindex” all pages I do import with WPAllImport.
I found a similar question about this here:
Therefore I tried to add
rank_math_robots
with the value “0”, “1”, “2” and “noindex” as individual field within WPAllImport but nothing changed, the pages are still set to “index”.
Do you have any idea how I can solve this problem using RankMath?
Thanks in advance! π
-
Hello,
Thank you for contacting Rank Math and bringing your concern to our attention.
May I know if you have already tried to leave the value blank, and let Rank Math add the default robots meta to apply?
If not yet, please set the default Robots Meta to
No Index
in WordPress Dashboard > Rank Math > Titles & Meta > Global and hit Save Changes below then import the pages.
I hope that helps. Thank you, and looking forward to your update.
Hi there,
thanks for your very fast reply and suggestion.
Your solution works to set “noindex” to the imported sites.
The problem: ALL pages imported (with two different imports) are now set to “noindex”.
I can’t manually set pages to “index” as I’ve two imports creating constantly new pages: one import has to generate sites with “index” and the other with “noindex”.
Therefore the problem is not solved yet. π
By the way resolving the problem would be also possible if there would be an option to set “noindex” either to specific Elementor Theme Templates (Single) or to specific taxonomy.
A third solution would be to use a hook with GeneratePress for the taxonomy I use if it would be possible to replace the RankMath code:
<meta name="robots" content="follow, index, max-snippet:-1, max-video-preview:-1, max-image-preview:large"/>
to this one:
<meta name="robots" content="follow, noindex, max-snippet:-1, max-video-preview:-1, max-image-preview:large"/>
Actually I can just “add” the 2nd code but it doesn’t delete/overwrite the 1st code.
Hope this helps and once more thank you for your support! π
Sorry for spam – nevermind my 3rd solution suggestion.
Even if I add the “noindex” it would work for the indexing issue BUT all sites will remain in the sitemap.xml.
Hello,
If you don’t want to include your post/page/CPT to your sitemap please check your sitemap setting by going Rank Math > Sitemap settings and disable the Include in sitemap option.
You can also do this for your custom taxonomies.
Please see the screenshot below:
I hope that helps, let us know if you have further questions.
Thank you.
Hello Febby,
this does not help me as with this option all pages will be removed from the sitemap.
As I’ve said I got two imports generating “pages” where I want to index the first import and noindex the second import.
It’s only possible to exclude a “post-tag-sitemap” but not to exclude “pages with the tags xyz”.
I would really appreciate if you could just give me information about how to use the command
rank_math_robots
to noindex instead of index sites. That would help me to resolve the problem.
Hello,
If there is a unique condition for the pages to be set as noindex/index, you can try the following function:
/** * Allows filtering of the robots meta data. * * @param array $robots The meta robots directives. */ add_filter( 'rank_math/frontend/robots', function( $robots ) { global $post; // filter for only a specific post type if($post_condition == true){ $robots['index'] = "index"; $robots['follow'] = "follow"; return $robots; } return $robots; });
Let me know if it helps.
Hi there,
first of all thank you for the function! π
Good news: it works perfectly to set “noindex” to specific pages that are listed with a special taxonomy.
Anyway bad news: I can’t get these now noindexed pages out of my sitemap.
I already tried out all the code snippets I found in this forum and within your FAQ but had no success yet.
I tried to use something like this:
add_filter( 'rank_math/sitemap/exclude_post_type', function( $exclude, $type ){ if ($type === 'post' && has_tag('MY-TAG-HERE')) { return false; } return $exclude; });
If we could manage to delete these noindexed pages from the sitemap would be perfect. π
Hello,
Thank you for following up.
Since they are already set to noindex, they should not appear in your sitemap. Could you please try flushing your sitemap cache by doing the steps in this screencast:
https://i.rankmath.com/pipRDpThen exclude the Sitemap files of the Rank Math plugin in your caching plugin. The cache could be via a plugin or from the server. For plugins or Cloudflare, please follow this article:
https://rankmath.com/kb/exclude-sitemaps-from-caching/If that didn’t help, you can also exclude posts/page manually by entering their ID here
And, hereβs how you find the post/page ID inside WordPress: https://mythemeshop.com/blog/how-to-find-post-category-tag-comments-or-user-id-in-wordpress/
I hope that helps. Thank you, and looking forward to your update.
Hello,
I already tried flushing all caches/cloudflare uncountable times and the pages are still within the sitemap.
I cannot exclude them manually as I said it is an automatic import creating these pages.
Therefore your answer unfortunately doesn’t help me.
Hello,
Here’s is another filter you can try:
add_filter( βrank_math/sitemap/xml_post_urlβ, function( $url, $post){ if (has_tag('MY-TAG-HERE')){ return false; } return $url; }, 10, 2 );
Let us know if this helps you.
Hi there,
no success with this function as well. Pages still remain in sitemap. π
Just in case someone else has the same problem:
I finally figured out how to noindex & remove pages from sitemap using WPAllimport.
The plugin Import Settings into WordPress SEO Plugin β Rank Math from WPAllimport does the job!
Therefore no need to add any function manually.
Hello,
We are super happy that this resolved your issue and thank you for letting us know.
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.
You must be logged in to reply to this ticket.