SEO Archives | Lee Willis https://www.leewillis.co.uk/tag/seo/ Tue, 01 Mar 2011 22:54:20 +0000 en-US hourly 1 https://wordpress.org/?v=6.7.2 Adding custom post type archives to your sitemap https://www.leewillis.co.uk/adding-custom-post-type-archives-to-your-sitemap/ https://www.leewillis.co.uk/adding-custom-post-type-archives-to-your-sitemap/#respond Tue, 01 Mar 2011 22:54:20 +0000 http://www.leewillis.co.uk/?p=362 The snippet below is a modification to Yoast’s excellent WordPress SEO plugin to include custom post type archives to the XML sitemaps it produces. Hope you find it useful. $post_type_archive_link = get_post_type_archive_link($post_type); if ($post_type_archive_link) { $url = array(); $url['loc'] = … Continue reading

The post Adding custom post type archives to your sitemap appeared first on Lee Willis.

]]>
The snippet below is a modification to Yoast’s excellent WordPress SEO plugin to include custom post type archives to the XML sitemaps it produces. Hope you find it useful.

            $post_type_archive_link = get_post_type_archive_link($post_type);
            if ($post_type_archive_link) {
                $url = array();
                $url['loc'] = $post_type_archive_link;
                $url['pri'] = 0.8;
                $url['chf'] = 'weekly';
                $this->write_sitemap_loc( $f, $url, $echo );
            }

Just add this snippet inside wp-content/plugins/wordpress-seo/sitemaps/xml-sitemap-class.php inside the function generate_sitemap. The code should go just inside the loop through the custom post types, e.g. after this chunk:

           if ( isset($options['post_types-'.$post_type.'-not_in_sitemap']) && $options['post_types-'.$post_type.'-not_in_sitemap'] )
                continue;
            if ( in_array( $post_type, array('revision','nav_menu_item','attachment') ) )
                continue;

Once you’ve added the code – just rebuild your Sitemap by visiting Seo » Dashboard » (Re)build XML Sitemap.

The post Adding custom post type archives to your sitemap appeared first on Lee Willis.

]]>
https://www.leewillis.co.uk/adding-custom-post-type-archives-to-your-sitemap/feed/ 0