XML Sitemap Support For Custom Post Type Using JetPack

So, in your site, you are using the XML Sitemap support using the JetPack plugin in your site, and could not see the sitemap for the Custom Post Type, as example for bbpress, WooCommerce,etc plugins in your site. Hence, you are seeking on help to about how to make them included in the sitemap generated by JetPack plugin. So, you have came in the right place. Here, we will describe about the xml sitemap support for custom post type, about how to do it properly in your site.

jetpack

JetPack plugin is one of the most used plugin in many different site. It offers many of the functionality to be added in your site. But, to use some of its functionality in your site, then, you might need to link it to your WordPress.com account. Well, one of the module provided through this plugin is support for the XML sitemap. You can simply activate it via visiting JetPack->Settings->Sitemaps section and then just activate it. No more work is required after that.

Now, if you have activated it for your site, you can find the XML site of your site via this link: http://domain_name/sitemap.xml, if you are using it on the live domain, and if you are using it via the localhost, then, it is likely to be http://localhost/wordpress_install/sitemap.xml. Now, if you visit that link in your site, then, the below screenshot will probably be displayed in your browser:

sitemap-no-custom-type-support

Also, we will take the example of the plugin bbpress here, to add the XML sitemap support for it using this plugin.

Now, after all is being setup in our local development environment, we have activated the bbpress plugin too and created the forum too. But, while we navigate to the sitemap url for our site, then, we could not see the support for the bbpress plugin at all. So, we have found out the solution on it how to add the support for it and hence, we will be sharing it with you.

By default, JetPack plugin will only create the XML sitemap for the posts, pages and custom post type generated by this plugin and does not support other custom post type at all. But, it has given you with the handy option for adding the custom post type support in the generation of sitemap. It has given you with the function  jetpack_sitemap_post_types to be  filtered out for adding for custom post type support in the sitemap generation. So, here, we will provide you with the code required to add those support. The code for it is given below:

Here, in the above code, we have created the custom function named as  theme_slug_add_bbpress_sitemaps_jetpack, to add the JetPack sitemap support for the forum custom post type only. But, this plugin too creates the topic and replies too, as you may know. But, above code will not create those for the unsupported custom post type, ie, that is not added to be supported in the code above. So, it might come it in your head about how to add more custom post type support. Is it required to create function every time to support the custom post type at all using this plugin? The answer for it would be no, you just can add up the required post type in the array above as you need them. Here, we will add up all of the support as an example for the bbpress  plugin, which is below:

Now, it might come in about where to add it up the above provided code in your site, right? Well, since this is the site specific issue and no one knows which plugin might be used in your site. So, the theme developer probably does not add it to their theme code at all. So, the answer to would probably be, if you can create the child theme for your site, then, grab up the above code and then paste it to the functions.php of the child theme. In case if you do not know how to create the child theme, then, you can follow this link.

And after you have done those changes in your child theme file, you can see that the sitemap now have all of the bbpress content in it, as shown below in the screenshot in your site too:

sitemap-custom-type-support

Also, for fast indexing of your site in the search engines, this file is required. So, if you build any of your site, then, this is one of the most important feature which is required. Hence, now we can assume that you know how to make the XML sitemap support for custom post type using JetPack. So, make it your own and grab much more visitor in your site by submitting it to the webmaster tools as soon as possible.

Note: JetPack plugin might restrict you to generate the entry of the XML sitemap content to the last 1000 entries from your site due to the server load and resources issue. So, if you do not prefer to use it at all, then, you can use other plugin for it in your site instead.

, , , , , , , , , , , , , ,

Post navigation

Bishal Napit

Bishal Napit is a WordPress theme developer from Tansen, Palpa, with a passion to learn more on WordPress.

Leave a Reply