Created
August 4, 2013 22:30
-
-
Save Clorith/6152213 to your computer and use it in GitHub Desktop.
WordPress hook and function to display various posts and custom post types on author pages
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Function for modifying the main query | |
*/ | |
function modify_the_loop( $query ) { | |
// Check that this is the main query, not a secondary one, and trigger if it's the author page' | |
if ( $query->is_main_query() && $query->is_author() ) | |
{ | |
$query->set( 'post_type', array( 'post', 'page', 'CPT', 'CPT2' ) ); | |
} | |
} | |
add_action( 'pre_get_posts', 'modify_the_loop' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment