wpseo_xml_sitemap_post_url

Filter the URL Yoast SEO uses in the XML sitemap.

Description

apply_filters( 'wpseo_xml_sitemap_post_url', (string) $get_permalink, (object) $post ); 

Note that only absolute local URLs are allowed as the check after this removes external URLs.

Parameters (2)

0. $get_permalink (string) => get_permalink( $post )
URL to use in the XML sitemap
1. $post (object)
Post object for the URL.

Usage

To run the hook, copy the example below.
  1. $get_permalink = apply_filters( 'wpseo_xml_sitemap_post_url', $get_permalink, $post ); 
  2.  
  3. if ( !empty( $get_permalink ) ) { 
  4.  
  5. // everything has led up to this point... 
  6.  
  7.  
The following example is for adding a hook callback.
  1. // define the wpseo_xml_sitemap_post_url callback 
  2. function filter_wpseo_xml_sitemap_post_url( $get_permalink, $post ) { 
  3. // make filter magic happen here... 
  4. return $get_permalink
  5. }; 
  6.  
  7. // add the filter 
  8. add_filter( 'wpseo_xml_sitemap_post_url', 'filter_wpseo_xml_sitemap_post_url', 10, 2 ); 
To remove a hook callback, use the example below.
  1. // remove the filter 
  2. remove_filter( 'wpseo_xml_sitemap_post_url', 'filter_wpseo_xml_sitemap_post_url', 10, 2 ); 

Defined (1)

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

/inc/sitemaps/class-post-type-sitemap-provider.php  
  1. $url['loc'] = apply_filters( 'wpseo_xml_sitemap_post_url', get_permalink( $post ), $post );