New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XML Sitemap - Add support for post type archive pages and support to exclude them as well #155

Closed
arnaudbroes opened this Issue Apr 7, 2016 · 3 comments

Comments

Projects
None yet
4 participants
@arnaudbroes
Contributor

arnaudbroes commented Apr 7, 2016

XML Sitemap - Add support for post type archive pages and support to exclude them as well

@contactashish13

This comment has been minimized.

Contributor

contactashish13 commented Jan 15, 2018

PR: #1480

There could a tiny confusion on how this will work.

Current behavior: If the user checks no post types and checks date archives, the post archive pages are being included in the sitemap.

Changed behavior: I'm automatically including the date archives of the supported post types (can be switched off with a filter). So if the user checks product and post and date archives, it will show the date archives for these post types. If the user checks no post types and checks date archives, nothing will be included in the sitemap.

This might cause confusion because users currently expect date archives to be included even if none of the post types are checked. To support this case, I'm assuming that if no post type is checked for date archives then I need to assume that at least the "post" post_type is to be included. @wpsmort Let me know if this is alright.

contactashish13 added a commit to contactashish13/all-in-one-seo-pack that referenced this issue Jan 24, 2018

contactashish13 added a commit to contactashish13/all-in-one-seo-pack that referenced this issue Jan 26, 2018

contactashish13 added a commit to contactashish13/all-in-one-seo-pack that referenced this issue Feb 9, 2018

contactashish13 added a commit to contactashish13/all-in-one-seo-pack that referenced this issue Mar 17, 2018

Merge remote-tracking branch 'refs/remotes/semperfiwebdesign/master' …
…into semperfiwebdesign#155

# Conflicts:
#	tests/base/class-sitemap-test-base.php
#	tests/modules/sitemap/test-sitemap.php

@michaeltorbert michaeltorbert added this to the 2.7 milestone Mar 22, 2018

@wpsmort wpsmort modified the milestones: 2.7, 2.8 May 15, 2018

contactashish13 added a commit to contactashish13/all-in-one-seo-pack that referenced this issue Aug 21, 2018

@wpsmort

This comment has been minimized.

Member

wpsmort commented Aug 21, 2018

@contactashish13 I tested this and it did not work. Here's how it should work:

If a post type has an archive (https://codex.wordpress.org/Function_Reference/register_post_type#has_archive) then we should include that archive in the XML Sitemap if that post type is checked.

To test this follow these steps:

1). Create a custom post type and make sure that has_archive is set to true
2). Populate the post type with a couple of posts and make sure you can browse to the archive page. I created a CPT called Movies and was able to browse to mydomain.com/movies/ to view all my movies posts
3). Check the box for your CPT under XML Sitemap > Post Types to include your CPT content in the sitemap
4). Check the XML Sitemap, you should see your posts and the archive page. You should not need Date Archives or any other option checked for this to happen

Note that excluding them will be difficult because they don't have a page ID. We should discuss how to exclude them.

Let me know if you have any questions.

contactashish13 added a commit to contactashish13/all-in-one-seo-pack that referenced this issue Aug 24, 2018

@contactashish13

This comment has been minimized.

Contributor

contactashish13 commented Aug 24, 2018

@wpsmort I have addressed this. For excluding archive pages of certain post types, I've added a filter aiosp_sitemap_include_post_types_archives which can be used as below:

add_filter( 'aiosp_sitemap_include_post_types_archives', 'aiosp_sitemap_include_post_types_archives' );
function aiosp_sitemap_include_post_types_archives( $types ) {
    // to exclude an archive page of type 'xxx'
    unset( $types['xxx'] );
    return $types;
}

where $types is an array of post_type vs. a post of that type

@wpsmort wpsmort removed the Needs Testing label Aug 27, 2018

michaeltorbert added a commit that referenced this issue Aug 29, 2018

XML Sitemap - Add support for post type archive pages and support to …
…exclude them as well (#1480)

* XML Sitemap - Add support for post type archive pages and support to exclude them as well #155

* codeclimate

* codeclimate

* test case

* sync with master

* PR comments

#155 (comment)

* test case
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment