• Resolved shecky

    (@shecky)


    Hi!

    I need to add some NOT WordPress categories and pages in my site’s sitemap.
    I have created a function that uses the ‘wpseo_sitemap_index’ filter but that does not seem to work.

    This is my code:

    function add_sitemap_ec_items(){
    	$sitemap_custom_items = '<sitemap>
    		<loc>https://my.devsite.com/product_cat-sitemap.xml</loc>
    		<lastmod>2016-12-18T23:12:27+00:00</lastmod>
    	</sitemap>
    	<sitemap>
    		<loc>https://my.devsite.com/product-sitemap1.xml</loc>
    		<lastmod>2016-12-18T23:12:27+00:00</lastmod>
    	</sitemap>
    	<sitemap>
    		<loc>https://my.devsite.com/product-sitemap2.xml</loc>
    		<lastmod>2016-12-18T23:12:27+00:00</lastmod>
    	</sitemap>';
    
    	return $sitemap_custom_items;
    }
    add_filter( 'wpseo_sitemap_index', 'add_sitemap_ec_items' );

    Any suggestions?

    • This topic was modified 7 years, 11 months ago by shecky.
Viewing 6 replies - 1 through 6 (of 6 total)
  • Did you try to deactivate/activate plugin after this?

    Please try to disable/enable XML Sitemap in SEO settings. It’s helpful to purge all caches and delete transients if you can. If it doesn’t show after this, please write more details.

    Thread Starter shecky

    (@shecky)

    Thanks for replies, Sa?a.

    I solved the problem adding the filter
    add_filter( “wpseo_enable_xml_sitemap_transient_caching”, “__return_false” );

    Regards!

    It isn’t good because you blocked Yoast caching and your sitemaps are too slow (and it can be SEO issue). If you are changing the code, you need to delete transients (I think that deactivation/activation of the plugin is enough).

    You should remove this line (filter wpseo_enable_xml_sitemap_transient_caching) and disable caching by cache plugins. You can use my filter (you can find it on github) or via settings in the plugins (you can find posts related to Supercache and W3TC). It’s better approach. If you are adding/removing your code related to sitemaps, you should delete transients or deactivate/activate plugin.

    It’s well-meaning advice. I hope that’s helpful.

    • This reply was modified 7 years, 11 months ago by Sa?a.
    Thread Starter shecky

    (@shecky)

    Thanks Sa?a.

    Like you suggested I removed the filter “wpseo_enable_xml_sitemap_transient_caching”.
    I find your filter on github but I not found it…
    In my site use W3TC with Yoast SEO plugin extension: how can I disable caching for sitemap pages?

    Regards.

    Thread Starter shecky

    (@shecky)

    I have another problem.
    In Yoast SEO Dashboard there is this notice:
    `These files are preventing the proper functioning of your XML sitemaps. Delete them (using the “Edit” button) or disabling the XML sitemapx the Yoast SEO:
    – …/product_categories-sitemap.xml
    – …/product_groups-sitemap.xml
    – …
    – … (list of all my custom sitemaps).

    Any suggestions?

    Go to Performance -> Settings, find Never cache the following pages. Bellow wp-.*\.php and index\.php, add:

    sitemap(_index)?\.xml(\.gz)?
    ([a-z0-9_\-]+)?sitemap\.xsl
    [a-z0-9_\-]+-sitemap([0-9]+)?\.xml(\.gz)?
    

    You can remove these pages from Non-trailing slash pages:

    Also, you need to exclude these pages from minify, if you use this feature. You can find some info about it on yoast website.

    I can copy the code here if it doesn’t work.

    Related to notice in SEO Dashboard, you can try to move xml files to some subdirectory. It should work because plugin check files only in root directory. (I’d guess. I didn’t check all details).

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Include non WordPress categories and pages in main sitemap’ is closed to new replies.