wpseo_xml_sitemap_post_priority

Filter the priority of the URL Yoast SEO uses in the XML sitemap.

Description

apply_filters( 'wpseo_xml_sitemap_post_priority', (float) $return, (string) $post_post_type, (object) $post ); 

Parameters (3)

0. $return (float)
The priority for this URL, ranging from 0 to 1
1. $post_post_type (string)
The post type this archive is for.
2. $post (object)
The post object.

Usage

To run the hook, copy the example below.
  1. $return = apply_filters( 'wpseo_xml_sitemap_post_priority', $return, $post_post_type, $post ); 
  2.  
  3. if ( !empty( $return ) ) { 
  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_priority callback 
  2. function filter_wpseo_xml_sitemap_post_priority( $return, $post_post_type, $post ) { 
  3. // make filter magic happen here... 
  4. return $return
  5. }; 
  6.  
  7. // add the filter 
  8. add_filter( 'wpseo_xml_sitemap_post_priority', 'filter_wpseo_xml_sitemap_post_priority', 10, 3 ); 
To remove a hook callback, use the example below.
  1. // remove the filter 
  2. remove_filter( 'wpseo_xml_sitemap_post_priority', 'filter_wpseo_xml_sitemap_post_priority', 10, 3 ); 

Defined (1)

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

/inc/sitemaps/class-post-type-sitemap-provider.php  
  1. $return = apply_filters( 'wpseo_xml_sitemap_post_priority', $return, $post->post_type, $post );