• Resolved mellowmarsh

    (@mellowmarsh)


    The sitemap generated is including my site header which is a custom post type. How do I make it so that this isn’t included in my generated sitemap?

    Thanks!

    The page I need help with: [log in to see the link]

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Sybre Waaijer

    (@cybr)

    Hi @mellowmarsh,

    The “premium” theme team UpSolution has registered the post type us_header in all their themes, and that templating post type shouldn’t have rewrite access — yet it does.

    Unfortunately, they disregarded the issue.

    But I digress. To quickly resolve this, add the following snippet to your (child-)theme’s functions.php file:

    add_filter( 'the_seo_framework_sitemap_exclude_cpt', function( $excluded = array() ) {
    
    	$excluded[] = 'us_header';
    
    	return $excluded;
    }, 10 );

    I hope this helps 🙂 Cheers!

    • This reply was modified 7 years, 11 months ago by Sybre Waaijer. Reason: Code error
    Thread Starter mellowmarsh

    (@mellowmarsh)

    Hi @cybr,

    Thanks for the quick response! That’s unfortunate that they haven’t fixed that issue. I added that code into my child theme functions.php file and now get this error: “Parse error: syntax error, unexpected ‘;’ in /wp-content/themes/Impreza-child/functions.php on line 5

    Any idea what I did wrong?

    Thanks!

    Plugin Author Sybre Waaijer

    (@cybr)

    Hi @mellowmarsh,

    My bad! I made a typo, and just fixed the code above.

    Here it is again for good measure:

    add_filter( 'the_seo_framework_sitemap_exclude_cpt', function( $excluded = array() ) {
    
    	$excluded[] = 'us_header';
    
    	return $excluded;
    }, 10 );

    Cheers 🙂

    Thread Starter mellowmarsh

    (@mellowmarsh)

    Hi @cybr,

    Awesome thank you! No error now but the /us_header/site-header/ is still showing up in my sitemap.

    Any ideas?

    Thanks!

    Plugin Author Sybre Waaijer

    (@cybr)

    Hi @mellowmarsh,

    That’s great!

    Update any post, or change a setting back and forth in the SEO settings, and the sitemap should refresh 🙂

    Thread Starter mellowmarsh

    (@mellowmarsh)

    Hi @cybr,

    Perfect! All good now, I really appreciate your help. This is my first time using your plugin and I love it. Awesome work!

    Thanks again, Cheers! 🙂

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

The topic ‘Exclude Custom Post Type from sitemap’ is closed to new replies.