• Skip to main content
  • Skip to header right navigation
  • Skip to site footer
LegitWebs

LegitWebs

Bay Area Website Design

  • Home
  • Blog
  • Services
  • Portfolio
  • About
  • Contact
Bay Area Web Design

Add Custom Post Types to Jetpack Sitemap

April 10, 2016 by Alex

By default the Sitemap module of the Jetpack plugin for WordPress does not include custom post types in its generated sitemap.xml.

I’m going to demonstrate some methods for adding this functionality to your WordPress website:

Method 1 – Add to an existing array

This site uses a custom portfolio post-type that is created in the theme’s functions.php, this is how it looks:

//* Create portfolio custom post type
add_action( 'init', 'bayareawebs_portfolio_post_type' );
function bayareawebs_portfolio_post_type() {
 
	register_post_type( 'portfolio',
		array(
			'labels' => array(
				'name'          => __( 'Portfolio', 'bayareawebs' ),
				'singular_name' => __( 'Portfolio', 'bayareawebs' ),
			),
			'has_archive'  => true,
			'hierarchical' => true,
			'menu_icon'    => get_stylesheet_directory_uri() . '/lib/icons/portfolio.png',
			'public'       => true,
			'rewrite'      => array( 'slug' => 'portfolio', 'with_front' => false ),
			'supports'     => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'trackbacks', 'custom-fields', 'revisions', 'page-attributes', 'genesis-seo', 'genesis-cpt-archives-settings' ),
			'taxonomies'   => array( 'portfolio-type' ),
 
		)
	);
 
}

On line 16 simply add ‘jetpack_sitemap_post_types’, the end result will look like this

'supports'     => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'trackbacks', 'custom-fields', 'revisions', 'page-attributes', 'genesis-seo', 'genesis-cpt-archives-settings', 'jetpack_sitemap_post_types'

Method 2 – Add Filter in Functions.php

This method is a bit more dirty than the last, it is copied from this page in the WordPress forums. Simply copy and paste this into your functions.php and replace your_post_type with the the post type you want to add.

function jeherve_add_cpt_sitemaps( $post_types ) {
	$post_types[] = 'your_post_type';
	return $post_types;
}
add_filter( 'jetpack_sitemap_post_types', 'jeherve_add_cpt_sitemaps' );

Method 3 – Edit the Jetpack Plugin

This isn’t a very good method as a plugin update will overwrite it. You can head to /wp-content/plugins/jetpack/modules/sitemaps/sitemap.php and on line 268 add an extra post type, it would look something like this:

$post_types    = apply_filters( 'jetpack_sitemap_post_types', array( 'post', 'page', 'portfolio' ) );

Last Step

Publish and delete a post or page, that will run a cron job to generate a new sitemap.

Category: ArticlesTag: Tutorial, WordPress
Previous Post:WordPressHow to edit WordPress (Video)
Next Post:Sitebuilder.com IMAP POP SMTP Settingslegitwebs

Reader Interactions

Comments

  1. khuong

    August 27, 2016 at 4:33 AM

    all method Not work

    Reply
    • Alex

      November 11, 2016 at 4:42 PM

      It is working on this site, among others, using first method. Jetpack is outputting the following sitemap: http://www.legitwebs.com/sitemap.xml

      Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Let’s work together

We specialize in working with local businesses. Find out what LegitWebs can do.

Contact Us

CONTACT INFO

LegitWebs
Walnut Creek, CA 94596
415.935.4441
alex@legitwebs.com

SOCIAL MEDIA

Follow along with our latest events and news.

  • Google
  • Yelp
  • Facebook
  • Twitter
  • LinkedIn
  • YouTube

QUICK LINKS

  • About Us
  • Contact Us
  • Payments
  • Services
  • Sitemap

Copyright © 2025 · LegitWebs · All Rights Reserved · Terms & Privacy

Return to top