wpseo_xml_sitemaps_init

Initialize sitemaps.

Description

wpseo_xml_sitemaps_init(); 

Add sitemap & XSL rewrite rules and query vars


Usage

  1. if ( !function_exists( 'wpseo_xml_sitemaps_init' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'yoast-seo/inc/wpseo-functions-deprecated.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = wpseo_xml_sitemaps_init(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/inc/wpseo-functions-deprecated.php  
  1. function wpseo_xml_sitemaps_init() { 
  2. _deprecated_function( __FUNCTION__, 'WPSEO 2.4', 'WPSEO_Sitemaps_Router' ); 
  3.  
  4. $options = get_option( 'wpseo_xml' ); 
  5. if ( $options['enablexmlsitemap'] !== true ) { 
  6. return; 
  7.  
  8. // Redirects sitemap.xml to sitemap_index.xml. 
  9.  
  10. if ( ! is_object( $GLOBALS[wp] ) ) { 
  11. return; 
  12.  
  13. $GLOBALS[wp]->add_query_var( 'sitemap' ); 
  14. $GLOBALS[wp]->add_query_var( 'sitemap_n' ); 
  15. $GLOBALS[wp]->add_query_var( 'xsl' ); 
  16. add_rewrite_rule( 'sitemap_index\.xml$', 'index.php?sitemap=1', 'top' ); 
  17. add_rewrite_rule( '([^/]+?)-sitemap([0-9]+)?\.xml$', 'index.php?sitemap=$matches[1]&sitemap_n=$matches[2]', 'top' ); 
  18. add_rewrite_rule( '([a-z]+)?-?sitemap\.xsl$', 'index.php?xsl=$matches[1]', 'top' );