Hello @jasnon
Thanks for reaching out regarding your sitemap. You can do it the other way around. Toggle the button to ‘Show posts in search results’. This creates a post-sitemap. Next, for posts you don’t want to be indexed, you can use the ‘Advanced’ tab of the Yoast SEO meta box to change the setting ‘Allow search engines to show this Post in search results?’ to NO.
Another alternative is to use the filter wpseo_exclude_from_sitemap_by_post_ids to exclude post types based on post IDs. Please take a look at our developer portal.
Thread Starter
jasnon
(@jasnon)
Hi @maybellyne thank you for the response. Since most of the posts on my site are user generated it is not possible to individually change the setting in the ‘Advanced’ tab on each post to NO.
Looking through the developer portal for how to exclude posts using the filter, I’m not seeing a way in which I can exclude all posts except post ID XYZ. Or exclude all posts under certain categories.
I basically just need the ability to exclude all posts on my site except maybe 5 specific posts that were created by me.
Can you provide more information on what you mean by user-generated? You may also provide us with screenshots. You can use any image-sharing service like https://pasteboard.co/, https://snag.gy/, https://imgur.com/, https://snipboard.io/, or even upload the screenshot to your own website. Once you upload it to an image-sharing service, please share the link to the image here.
-
This reply was modified 3 years, 3 months ago by
Maybellyne.
Thread Starter
jasnon
(@jasnon)
Hi @maybellyne thanks for the reply. 99% of the posts on my site are created by users via a Gravity Form. These posts are membership pages which is why I don’t want them included in my post sitemap or indexed by search engines.
As the site admin however, I do create a few posts for educational purposes (marketing landing pages, etc.) and these are the only posts I would like included in the sitemap and indexed by search engines.
This is why by default I have the global setting of posts toggled to OFF so the 99% don’t get indexed, and then I change the advanced settings of each individual post I create as admin to ON so those do get indexed. They don’t however show up in my site map and that’s the problem I’m trying to solve.
Hope that helps explains things better.
Thanks for the feedback, @jasnon. I can’t test this since Gravity Forms is a premium plugin. However, note that a post sitemap won’t be created once you toggle the global settings for posts OFF. So it’s better to turn it ON to have the post sitemap then individually noindex the ones you don’t want to be indexed. If you have a lot of posts, I know it’s a lot of work, but I can’t think of a better alternative.
Thread Starter
jasnon
(@jasnon)
@maybellyne thanks for the reply. Is there a way to exclude all posts under a specific category (or multiple categories) using the methods shown in the article here?
https://developer.yoast.com/features/xml-sitemaps/api/#excluding-content-types
Yes. You could test out the wpseo_sitemap_exclude_post_type filter to exclude a post type
Thread Starter
jasnon
(@jasnon)
@maybellyne excluding the post type ‘post’ would exclude all posts though wouldn’t it? how could I only exclude posts under a specific category?
According to WordPress documentation, a standard post will have two taxonomy types called Categories and Tags. So you could try the filter to exclude taxonomy