WordPress.org

Plugin Directory

Sewn In XML Sitemap

Simple way to automatically generate XML Sitemaps when a page or post is saved. Very simple, no cruft or extra features you won't use.

2.0.3 changed default post types used from only 'post' and 'page' to ALL public post types except "attachment". This is a cleaner approach, but may require customization. Ther is more info on customization below.

Simple way to automatically generate XML Sitemaps when a page or post is saved. Very simple, no cruft or extra features you won't use. There are two main customizations available.

  • Choose which post types are added (posts and pages by default)
  • Adds a meta box to all included post types to remove single posts from being added to the sitemap

It also works well with our Sewn In Simple SEO plugin. When both are installed, they integrate together.

Control what post types are added

By default only pages and posts are added, but you can remove either of those and/or add more using this filter:

/**
 * Add a post type to the XML sitemap
 *
 * Takes the default array('post','page') and adds 'news' and 'event' post types 
 * to it. Returns: array('post','page','news','event')
 *
 * @param   array   $post_types List of post types to be added to the XML Sitemap
 * @return  array   $post_types Modified list of post types
 */
add_filter( 'sewn/seo/post_types', 'custom_seo_post_types' );
function custom_seo_post_types( $post_types )
{
    $post_types[] = 'news';
    $post_types[] = 'event';
    return $post_types;
}
/**
 * Completely replace the post types in the XML sitemap
 *
 * This will replace the default completely. Returns: array('news','event')
 *
 * The result is to remove 'post' and 'page' post types and to add 'news' and 
 * 'event' post types
 *
 * @param   array   $post_types List of post types to be added to the XML Sitemap
 * @return  array   $post_types Modified list of post types
 */
add_filter( 'sewn/seo/post_types', 'custom_seo_post_types' );
function custom_seo_post_types( $post_types )
{
    $post_types = array('news','event');
    return $post_types;
}

Remove a specific post from the sitemap

A checkbox is added to each post type that is included in the sitemap. Checking it will remove that specific item from the sitemap.

This checkbox also removes posts from wp_list_pages, you can turn that off using this filter:

add_filter( 'sewn/sitemap/wp_list_pages', '__return_false' );
/**
 * This filter arrived in 2.0.3
 *
 * Remove specific posts programatically. This could go into functions.php or a plugin.
 *
 * This example removes all posts that have post meta field of "test" set.
 */
add_filter( 'sewn/sitemap/post', 'custom_remove_test_posts', 10, 2 );
function custom_remove_test_posts( $value, $post )
{
    $status = get_metadata( 'post', $post->ID, 'test', true );
    if ( $status ) {
        $value = false;
    }
    return $value;
}

Compatibility

Works with the Sewn In Simple SEO plugin. When installed, the XML sitemap checkbox integrates with the SEO fields and this plugin will use the SEO post types. The goal is to keep things very simple and integrated.

Requires: 3.6.1 or higher
Compatible up to: 4.2.4
Last Updated: 2015-7-27
Active Installs: 80+

Ratings

5 out of 5 stars

Support

Got something to say? Need help?

Compatibility

+
=
Not enough data

0 people say it works.
0 people say it's broken.

100,1,1
100,1,1