Skip to content

Instantly share code, notes, and snippets.

@amboutwe
Last active January 30, 2024 00:11
Show Gist options
  • Save amboutwe/d51f6beae6d81a5fecd04d726dd69f46 to your computer and use it in GitHub Desktop.
Save amboutwe/d51f6beae6d81a5fecd04d726dd69f46 to your computer and use it in GitHub Desktop.
<?php
/********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/
/* Include authors of CPTs in the Yoast author sitemap
* Credit: Yoast team
* Last Tested: Jan 29 2024 using Yoast SEO 21.9.1 on WordPress 6.4.2
* For optimial SEO, please ensure that CPT posts are included in the core author archive output
* Example: https://wpdevdesign.com/how-to-add-cpt-entries-in-author-archives/
*/
add_filter( 'wpseo_author_archive_post_types', 'yoast_seo_sitemap_add_cpt_authors');
function yoast_seo_sitemap_add_cpt_authors ( $currentPostTypes ) {
$addPostTypes = []; // Do not remove this line
array_push( $addPostTypes, "book" ); // Repeat to add another post type
array_push( $addPostTypes, "movie" ); // Repeat to add another post type
//Do not remove the lines below
$newPostTypeArray = array_unique( array_merge( $currentPostTypes, $addPostTypes ));
return $newPostTypeArray;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment