• Hi folks!

    I’m a little stumped by a recent issue i’ve been having, in that the author post count in admin doesn’t seem to include custom post types, nor do they show up on the auto-generated author pages.

    Is there some code snippet I need to install for WordPress to include them? When I build the CPT, they’re all left at ‘public’ => true, so anything should be able to access them. Also, ‘author’ is set in the capabilities array.

    Any and all insights are appreciated!

Viewing 5 replies - 1 through 5 (of 5 total)
  • ^ something I actually know

    The predefined query for author pages only has the normal post type in it.

    add_filter('pre_get_posts', 'mytheme_query_author_pages');
    
    function mytheme_query_author_pages($query) {
    	if (is_author() && empty( $query->query_vars['suppress_filters'] ) ) {
    		$post_type = get_query_var('post_type');
    		if($post_type) :
    			$post_type = $post_type;
    		else:
    			$post_type = array('post','yourcustomposttype');
    			$query->set('post_type',$post_type);
    		endif;
    		return $query;
    	}
    }

    This will add the custom post type in the pre get posts for author pages..

    if (is_author()) doesn’t work you can check by query var

    if (get_query_var('author_name') || get_query_var('author')) {

    modify this to suit, cause unknown if post type is set when query var for author is present

    Thread Starter Evan Jacobs

    (@iridox)

    Thanks Frumph! I tried something similar to this earlier, and it DID include the posts on the archive, but not in the admin panel.

    Does your version also include the CPT in the admin author post count?

    Neg, but I bet there’s a filter for that..

    You want it to display how many posts are in the users profile page ya?

    Is that what you mean by the author post count?

    Trying to picture where that count is ;/

    let’s say yes ??
    (same situation and can’t believe the guy just bailed!)

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Author Count and Custom Post Types’ is closed to new replies.