I've created a few custom post types based on Dave Rupert's boilerplate and then migrated existing posts to these newly created CPTs via Post Type Switcher plugin. I did not make any changes to the boilerplate apart from changing CPT name and support* attributes.

'supports' => array(

Migrated posts correctly display their authors and it is possible to change posts' author. However, when I view author list in Users section, the post counter for non-admin authors is zero (0). Temporarily changing author role to admin and back again does not help to show the correct count of posts for individual authors.

I checked the database records as well (pls check view from wp_posts table below). Authors IDs seem to be correctly assigned to individual posts. Still I think I broke the post-author relation somewhere in the database, but I can figure out where.

Does anyone know how to tackle this issue?

view from wp_posts table

  • By default, custom post types are not counted Commented Jul 24, 2014 at 15:34
  • Thank You! Found this answer in a Google Search and it worked perfectly for my needs.
    – jaypeg
    Commented Apr 17, 2019 at 23:52

1 Answer 1


This is an answer I re-porpoised from a question that was abandoned. I thought this will help you solve this issue

By default, all custom post types are excluded from the main query, that is why you don't see any posts when going to the front end author page. To accomplish this, you will need to modify the main query to include these post type/s. For this purpose, you are going to use the pre_get_posts action hook. You will also use the conditional tag is_author() to check that you are on the author archive page. (I've tested this code using my custom post types event_type and cameras, so just change this accordingly)

function custom_post_author_archive($query) {
    if ($query->is_author() && $query->is_main_query() )
        $query->set( 'post_type', array('event_type', 'cameras', 'post', 'page') );
add_action('pre_get_posts', 'custom_post_author_archive');

To tackle the problem of post count in the back end, I think it will be a good idea to unset the posts column in the authors page, and then to replace it with a new column that will count all the post types, ie event_type, post and page. You can edit this accordingly

Here you will make use of manage_users_columns and manage_users_custom_column which is not very well documented.

function add_extra_user_column($columns) { //Add CPT Column for events and remove default posts column
    return array_merge( $columns, 
              array('foo' => __('Posts')) );
add_filter('manage_users_columns' , 'add_extra_user_column');

function add_post_type_column( $value, $column_name, $id ) { //Print event_type value
  if( $column_name == 'foo' ) {
    global $wpdb;
    $count = (int) $wpdb->get_var( $wpdb->prepare(
      "SELECT COUNT(ID) FROM $wpdb->posts WHERE 
       post_type IN ('event_type', 'cameras', 'post', 'page') AND post_status = 'publish' AND post_author = %d",
    ) );

    if ( $count > 0 ) {
        $r = "<a href='edit.php?author=$id'>";
        $r .= $count;
        $r .= '</a>';
    } else {
        $r = 0;

    return $r;

add_filter( 'manage_users_custom_column', 'add_post_type_column', 10, 3 );
  • Did not get any feedback from you. Just checking back in to see if you've solved your problem.If yes, and you've used my solution, please consider accepting my answer by clicking on the check mark next to my answer. If you've used another solution, please consider posting it as an answer and accept your own answer. If it is not solved, what are you struggling with Commented Jul 25, 2014 at 9:38
  • Pieter, I did use the first function and it worked great for author archives. However I didn't use the second function for fixing post count as it is no longer needed to display counter on backend.
    – Metin
    Commented Jul 26, 2014 at 17:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.