Skip to content

Instantly share code, notes, and snippets.

@amboutwe
Last active September 25, 2025 23:18
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.

Revisions

  1. amboutwe revised this gist Jan 30, 2024. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions wpseo_author_archive_post_types.php
    Original file line number Diff line number Diff line change
    @@ -4,6 +4,8 @@
    /* 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');
  2. amboutwe created this gist Jan 30, 2024.
    20 changes: 20 additions & 0 deletions wpseo_author_archive_post_types.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    <?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
    */

    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;
    }