• Skip to primary navigation
  • Skip to main content

Genesis Community

Resources for Genesis WordPress Theme Users

  • Facebook
  • Twitter
  • Slack
  • Wiki
  • Login
You are here: Home / Wikis / WordPress / Add Custom Post Type entries to Author Archives

Add Custom Post Type entries to Author Archives

add_action( 'pre_get_posts', 'post_types_author_archives' );
/**
 * Adds `wiki` Custom Post Type to Author Archives.
 */
function post_types_author_archives( $query ) {

    // Adds 'wiki' post type to author archives.
    if ( $query->is_author ) {
        $query->set( 'post_type', array( 'post', 'wiki' ) );
    }

    // Remove the action after it's run.
    remove_action( 'pre_get_posts', 'post_types_author_archives' );
}
Source: https://gist.github.com/Kevinlearynet/4216718

Posted by: Sridhar Katakam Category: WordPress Tags: author archives, pre_get_posts

« Show all posts on archives
Add Categories and Tags support to CPT »

Copyright © 2026 · Genesis Sample on Genesis Framework · WordPress · Log in