str_replace a custom post type index
-
Hello,
I am using WP Job Manager on a site and it forces the custom post type index to be /job-listings/ but we have used some custom PHP to make it render on /jobs/ and 301 redirect.
The issue is that the sitemap for this post type still contains /job-listings/ at the top of the sitemap and ahrefs warns us about including a 301 in the sitemap.
I have tried using variations of
function sitemap_post_url( $url, $post ) { if ( $post->post_type === 'guest_authors' ) { return \str_replace( 'guest-authors', 'guests', $url ); } return $url; } add_filter( 'wpseo_xml_sitemap_post_url', 'sitemap_post_url', 10, 2 );
from https://developer.yoast.com/features/xml-sitemaps/api/#exclude-specific-posts but haven’t been able to make it change the index archive URL included in the sitemap.
Any ideas?
Thanks in advance.
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘str_replace a custom post type index’ is closed to new replies.