help to write a custom php script to settingup yoast priority to pages or posts
I'm trying to improve this tutorial script including a switch
in the first if
condition to assign a custom priority
to my Yoast Xml Sitemap only to certain post or pages.
So i'm trying to say to Yoast which if some pages have certain id
the priority
have to change, but my script assign the 0.5 value to all pages.
Any help?
add_filter( 'wpseo_xml_sitemap_post_priority', 'my_custom_post_xml_priority', 10, 3 );
function my_custom_post_xml_priority( $return, $type, $post) {
if($type == 'page') {
switch ($post) {
case '8':
case '395':
case '342':
$return = 0.9;
case '5':
$return = 1.00;
case '620':
case '703':
case '603':
case '688':
case '695':
case '614':
case '684':
case '639':
case '628':
case '539':
case '542':
case '521':
case '509':
case '517':
case '528':
case '533':
case '536':
case '548':
case '545':
case '525':
case '551':
$return = 0.7;
break;
default:
$return = 0.5;
break;
}
}
elseif ($type == 'post') {
$return = 0.8;
}
return $return;
}
Topic switch plugin-wp-seo-yoast Wordpress
Category Web