-
Hi,
I want to disable indexing of archive pages of my custom post types and according to the tutorial, I navigate to Titles & Meta -> Choose the custom post type and enable “[CPT-name] Robots Meta”.I only get to see the [CPT] Robot meta, but nothing for archives that I need to change.
The CPT has archives set up, I checked.
In Misc Pages, I enabled Noindex subpages – not sure if it’s related and what I want.
Can you please help me to set noindex on the archives of my CPTs?
Best,
Jan
-
Hello,
We apologize for the issue you are facing with setting Noindex for the archive pages of your custom post types (CPTs). It seems like you are on the right track by navigating to the Titles & Meta settings. However, if you are not seeing the option to set Noindex for the archives of your CPTs, it could be due to a few reasons.
Here’s what you can do:
- Check Archive Settings: Ensure that the archive settings for your custom post type are correctly configured. You mentioned that the archives are set up, but double-checking this can help.
- Enable Noindex for Archives: In the Titles & Meta settings, after selecting your custom post type, look for an option specifically labeled for archive pages. If it’s not visible, it might be a limitation of the current setup or theme.
- Miscellaneous Pages Settings: You mentioned enabling "Noindex subpages" in the Misc Pages section. This setting is generally for paginated content and may not directly affect the main archive pages of your CPTs.
- Manual Noindex: If the option is still not available, you might need to manually add a Noindex meta tag to the archive template of your custom post type. This would require some coding knowledge or assistance from a developer.
If these steps do not resolve your issue, we recommend replying to this ticket so a human agent from the Rank Math Support team can assist you further with this specific concern.
Thank you for raising this concern!
Hello,
The archive page’s robots meta is also controlled in the Titles & Meta settings as you explained above ([CPT] Robot meta).
However, you can use this filter to set only the archive page to noindex:
add_filter( 'rank_math/frontend/robots', function( $robots ) { if(is_archive('zajezd')) { //update to match the actual CPT name $robots['index'] = 'noindex'; $robots['follow'] = 'nofollow'; } return $robots; });
Here is how to add a filter to your site:
https://rankmath.com/kb/wordpress-hooks-actions-filters/Hope that helps.
Hi Reinelle,
Thanks a lot for the code snippet. Before I take that route, I made a short loom showing my website in case you find an error in my settings. I really don’t see it – it simply looks like I’m missing those sections there.https://www.loom.com/share/d072322828354376b0ac286bec77b2ad?sid=be9c79d5-958d-4d24-995c-6081c2d4afca
Best,
JanHello,
No, there’s nothing wrong with your setup and it is also the default behavior of Rank Math. The robots meta of the post type shares the values with its archive as well.
There’s no additional robots meta option below for the archive of each post type in the Titles & Meta settings. But if this is something that we’re able to introduce in the future, we’ll be sure to let you know.
In the meantime, you can use and customize the filter/code above to set the archive’s robots meta separately.
Looking forward to helping you.
Hi Reinelle,
I want to index the individual Tour post type posts. But I don’t want to index the Tour archive.To clarify: There is no toggle in the settings to allow that and I have to use the code snippet. Is my understanding correct?
If so, please, pass this request to your product team and consider adding it.
Best,
JanHi Reinelle,
I tried using the code snippet but I’ve run into some issues and inconsistencies. Could you please review my loom?
https://www.loom.com/share/fd127b50bcd64a078687eeb25e72ce8a?sid=3ebd41a1-bb32-479a-9490-627ef4f8d62aIn short, it seems to work fine for one custom post type, but not for another.
Best,
JanHello,
Yes, there’s no toggle button for archive robots meta in the settings.
Regarding the issue, please update the last line of the filter to this one and check if the robots meta are changed accordingly:
}, 99);
Let us know how this goes.
Hi Reinelle,
Thank you for the fix. It works very well for the Tour (Zajezd) custom post type. But it still doesn’t work for Guide (Pruvodce) post type.How should I fix it, please? What does 99 mean in there?
Best,
JanHello,
The number
99
in the filter sets the priority of the action. A higher number ensures that the filter runs later, allowing it to override other potential rules affecting the robots meta tags.To apply the filter for multiple custom post types (like “Guide” or “Tour”), you can update the condition to handle them both. Here’s an adjusted code snippet:
add_filter( 'rank_math/frontend/robots', function( $robots ) { if ( is_post_type_archive( ['zajezd', 'pruvodce'] ) ) { // Add all relevant CPTs here $robots['index'] = 'noindex'; $robots['follow'] = 'nofollow'; } return $robots; }, 99 );
This should ensure the archives for both “Zajezd” and “Pruvodce” custom post types are set to noindex while leaving individual posts unaffected.
We hope this helps.
Thank you.
Hi Ike,
Thanks a lot for the adjustment in the code. It works great! I appreciate your support.Best,
JanHello,
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.
The ticket ‘Noindex for archives in CPT missing’ is closed to new replies.