Author Count and Custom Post Types (6 posts)

  1. Evan Jacobs
    Posted 4 years ago #

    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!

  2. Frumph
    Posted 4 years ago #

    ^ 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;
    			$post_type = array('post','yourcustomposttype');
    		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

  3. Evan Jacobs
    Posted 4 years ago #

    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?

  4. Frumph
    Posted 4 years ago #

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

  5. Frumph
    Posted 4 years ago #

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

  6. Pirco the One and Only
    Posted 3 years ago #

    let's say yes :-)
    (same situation and can't believe the guy just bailed!)

Topic Closed

This topic has been closed to new replies.

About this Topic