Title: Sitemap custom type post
Last modified: August 24, 2017

---

# Sitemap custom type post

 *  Resolved [pfsm999](https://wordpress.org/support/users/pfsm999/)
 * (@pfsm999)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/sitemap-custom-type-post/)
 * Hi,
 * I try to understand the process of the sitemap inside Yoast.
 * I’ve got a sitemap.xml :
    [https://paul-fsm.net/sitemap_index.xml](https://paul-fsm.net/sitemap_index.xml)
 * My custom post type are declared with `public = true`.
 * **I don’t find my custom type post inside the main XML.**
    They are done when
   i go on : [https://paul-fsm.net/ecole-sitemap.xml](https://paul-fsm.net/ecole-sitemap.xml)
   or [https://paul-fsm.net/?sitemap=ecole](https://paul-fsm.net/?sitemap=ecole)
   [https://paul-fsm.net/emploi-sitemap.xml](https://paul-fsm.net/emploi-sitemap.xml)
   [https://paul-fsm.net/diplome-sitemap.xml](https://paul-fsm.net/diplome-sitemap.xml)…
 * For information : I use your htaccess instructions :
    [https://kb.yoast.com/kb/xml-sitemaps-apache/](https://kb.yoast.com/kb/xml-sitemaps-apache/)
 * **I use Yoast Free edition.**
    - I already try to disabled / enabled sitemap inside yoast : Nothing change.
    - I already try to desactivate / reactivate yoast plugin : Nothing change
    - I already try to empty the cache with W3 Cache : Nothing change
    - I already try to desactivate / reactivate W3 cache plugin : Nothing change
      again.
 * I check your code and i put some line in commentary :
 * Inside : **wordpress-seo/inc/sitemaps/class-sitemap.php** (line 224 & 226)
 *     ```
       public function redirect( $query ) {
   
       		if ( ! $query->is_main_query() ) {
       			return;
       		}
   
       		$xsl = get_query_var( 'xsl' );
   
       		if ( ! empty( $xsl ) ) {
       			$this->xsl_output( $xsl );
       			$this->sitemap_close();
   
       			return;
       		}
   
       		$type = get_query_var( 'sitemap' );
   
       		if ( empty( $type ) ) {
       			return;
       		}
   
       		$this->set_n( get_query_var( 'sitemap_n' ) );
   
       		//if ( ! $this->get_sitemap_from_cache( $type, $this->current_page ) ) {
       			$this->build_sitemap( $type );
       		//}
   
       		if ( $this->bad_sitemap ) {
       			$query->set_404();
       			status_header( 404 );
   
       			return;
       		}
   
       		$this->output();
       		$this->sitemap_close();
       	}
       ```
   
 * And when i do that : nothing change when i check the normal URL :
    [https://paul-fsm.net/sitemap_index.xml](https://paul-fsm.net/sitemap_index.xml)
 * BUT when i add a parameter : like that :
    [https://paul-fsm.net/sitemap_index.xml?toto=1](https://paul-fsm.net/sitemap_index.xml?toto=1)
 * The sitemap update with my custom post type !
    **AND I DON’T UNDERSTAND WHY !**
 * I try everything : Change my priority init hook for my custom post type, review
   all my code … don’t working !
 * Could you please help me ?
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fsitemap-custom-type-post%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 10 replies - 1 through 10 (of 10 total)

 *  [Suwash Kunwar](https://wordpress.org/support/users/suascat_wp/)
 * (@suascat_wp)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/sitemap-custom-type-post/#post-9437489)
 * [@pfsm999](https://wordpress.org/support/users/pfsm999/), you can configure in
   Yoast plugin settings whether or not to include the custom post type in your 
   sitemap. Please take a look at this guide: [https://kb.yoast.com/kb/how-to-customize-the-sitemap-index/](https://kb.yoast.com/kb/how-to-customize-the-sitemap-index/)
 *  Thread Starter [pfsm999](https://wordpress.org/support/users/pfsm999/)
 * (@pfsm999)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/sitemap-custom-type-post/#post-9437699)
 * **I already done that.**
    All my custom post type are allowed to have a sitemap!
 * > [View post on imgur.com](https://imgur.com/a/sVvXc)
 * I just don’t understand why they are not inside my main sitemap.
    [https://paul-fsm.net/sitemap_index.xml](https://paul-fsm.net/sitemap_index.xml)
 *  [Gal Baras](https://wordpress.org/support/users/galbaras/)
 * (@galbaras)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/sitemap-custom-type-post/#post-9439944)
 * Your sitemap may be cached (by W3 Total Cache). Clear the cache and check again
 *  Thread Starter [pfsm999](https://wordpress.org/support/users/pfsm999/)
 * (@pfsm999)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/sitemap-custom-type-post/#post-9439980)
 * Like i said : already done that !
    Nothing change !
 *  [Gal Baras](https://wordpress.org/support/users/galbaras/)
 * (@galbaras)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/sitemap-custom-type-post/#post-9440006)
 * When I go to the link with the URL parameter, I don’t see your custom post types.
 * Is there anything relevant in error_log?
 * Also, I think the sitemap is only rebuilt when you save its settings. Are you
   saving the settings after every code change?
 *  Thread Starter [pfsm999](https://wordpress.org/support/users/pfsm999/)
 * (@pfsm999)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/sitemap-custom-type-post/#post-9440092)
 * I can’t check my php log (My website is host by OVH who don’t give access to 
   PHP log).
    Inside my apache log : nothing relevant ! But if you want, i share
   my custom post type code in the github issue : [https://github.com/Yoast/wordpress-seo/issues/7759?_pjax=%23js-repo-pjax-containe](https://github.com/Yoast/wordpress-seo/issues/7759?_pjax=%23js-repo-pjax-containe)
 * And, see, the ecole sitemap don’t work, but diplome sitemap work …
    I don’t understand
   why … I know, the problem must be in my side … but where ?
 *  [Gal Baras](https://wordpress.org/support/users/galbaras/)
 * (@galbaras)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/sitemap-custom-type-post/#post-9440157)
 * Sorry, I don’t see a link to diplome in the sitemap index and the direct link
   you’ve supplied above gets a 404.
 * You could try to create your post types before “init”, or at least prioritise
   your initialisation code to run before that of Yoast SEO. See [https://codex.wordpress.org/Plugin_API/Action_Reference](https://codex.wordpress.org/Plugin_API/Action_Reference).“
   after_setup_theme” should be good if this is part of your theme. “plugins_loaded”
   might be good if your code is in a plugin.
 *  Thread Starter [pfsm999](https://wordpress.org/support/users/pfsm999/)
 * (@pfsm999)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/sitemap-custom-type-post/#post-9440588)
 * I just delete all sitemap cache (45 rows) inside my option table in my database:
   All custom post type sitemap work now !
 * But they don’t appear in my sitemap home again -_-.
    And i try to change the 
   Action Reference.
 * With `after_setup_theme` : My custom post type disapear from my admin menu … :
   not a good solution.
    And my code is not inside a plugin but inside my theme.
 *  Thread Starter [pfsm999](https://wordpress.org/support/users/pfsm999/)
 * (@pfsm999)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/sitemap-custom-type-post/#post-9440896)
 * Okay i find the issue 🙂
    Not a problem from YOAST but from my code ! To see 
   the solution : Go inside the GitHub ticket : [https://github.com/Yoast/wordpress-seo/issues/7759](https://github.com/Yoast/wordpress-seo/issues/7759)
 *  Thread Starter [pfsm999](https://wordpress.org/support/users/pfsm999/)
 * (@pfsm999)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/sitemap-custom-type-post/#post-9440898)
 * Close 🙂

Viewing 10 replies - 1 through 10 (of 10 total)

The topic ‘Sitemap custom type post’ is closed to new replies.

 * ![](https://ps.w.org/wordpress-seo/assets/icon-256x256.gif?rev=3419908)
 * [Yoast SEO - Advanced SEO with real-time guidance and built-in AI](https://wordpress.org/plugins/wordpress-seo/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wordpress-seo/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wordpress-seo/)
 * [Active Topics](https://wordpress.org/support/plugin/wordpress-seo/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wordpress-seo/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wordpress-seo/reviews/)

## Tags

 * [sitemap](https://wordpress.org/support/topic-tag/sitemap/)

 * 10 replies
 * 3 participants
 * Last reply from: [pfsm999](https://wordpress.org/support/users/pfsm999/)
 * Last activity: [8 years, 10 months ago](https://wordpress.org/support/topic/sitemap-custom-type-post/#post-9440898)
 * Status: resolved