Priority and Frequency
-
Hi, I need help with the right filter to enable priority and frequency to the sitemap.
I tried the below snippets and they are not working.
/**
- Modify the sitemap entry to include changefreq and priority.
* - @param array $url Array of URL parts.
- @param string $type URL type (post, user, or term).
- @param object $object Data object for the URL.
*/
add_filter( ‘rank_math/sitemap/entry’, function( $url, $type, $object ) {
if ( $type === ‘post’ ) {
$url[‘changefreq’] = ‘weekly’; // Set your desired frequency
$url[‘priority’] = ‘0.8’; // Set your desired priority
} elseif ( $type === ‘page’ ) {
$url[‘changefreq’] = ‘monthly’;
$url[‘priority’] = ‘0.6’;
} // Add more conditions for other types if needed
// if ( $type === ‘custom_post_type’ ) {
// $url[‘changefreq’] = ‘daily’;
// $url[‘priority’] = ‘0.9’;
// } return $url;
}, 10, 3 );
- Modify the sitemap entry to include changefreq and priority.
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- You must be logged in to reply to this topic.