0

Why is wp_list_authors not picking up Authors from CPT's when I have the supports option enabled? From what I have read elsewhere it looks like I have everything covered but the authors of CPT's refuse to show. I am trying to get the default post and CPT authors to show in one unified list. Could someone show me what I am doing wrong?

FUNCTIONS.PHP

// Registers a new post type
add_action( 'init', 'message_init' );

function message_init() {
$labels = array(
    'name'               => _x( 'Messages', 'post type general name', 'site' ),
    'singular_name'      => _x( 'Message', 'post type singular name', 'site' ),
    'menu_name'          => _x( 'Messages', 'admin menu', 'site' ),
    'name_admin_bar'     => _x( 'Message', 'add new on admin bar', 'site' ),
    'add_new'            => _x( 'Add New', 'message', 'site' ),
    'add_new_item'       => __( 'Add New Message', 'site' ),
    'new_item'           => __( 'New Message', 'site' ),
    'edit_item'          => __( 'Edit Message', 'site' ),
    'view_item'          => __( 'View Message', 'site' ),
    'all_items'          => __( 'All Messages', 'site' ),
    'search_items'       => __( 'Search Messages', 'site' ),
    'parent_item_colon'  => __( 'Parent Messages:', 'site' ),
    'not_found'          => __( 'No messages found.', 'site' ),
    'not_found_in_trash' => __( 'No messages found in Trash.', 'site' ),
);

$args = array(
    'labels'             => $labels,
    'description'        => __( 'Description.', 'site' ),
    'public'             => true,
    'publicly_queryable' => true,
    'show_ui'            => true,
    'show_in_menu'       => true,
    'query_var'          => true,
    'rewrite'            => array( 'slug' => 'connect/series/message' ),
    'capability_type'    => 'post',
    'has_archive'        => true,
    'hierarchical'       => false,
    'menu_position'      => null,
    'supports'           => array( 'title', 'editor', 'author', 'thumbnail', 'post-formats' ),
    'taxonomies'         => array( 'category' )
);

    register_post_type( 'message', $args );
}

PAGE WHERE AUTHORS ARE TO DISPLAY

<div class="authors_content">
        <h5>Authors</h5>
        <ul>
            <?php $args = array(
                'orderby'       => 'post_count', 
                'order'         => 'DESC', 
                'number'        => 5,
                'exclude_admin' => false, 
                'show_fullname' => false
            );
            wp_list_authors( $args ); ?>
            <li><a href="#">View All</a></li>
        </ul>
    </div>

CPT Template DECLARATION

/*
Template Name: Message Template
Template Post Type: post, messages
*/
0

Well, for one thing, 'DSC' is incorrect for the 'order' parameter. It should be 'DESC.'

  • Thanks that was a typo on my end but this does not address the issue. – Peter Oct 30 '18 at 19:27
  • If your authors haven't written any posts yet, you may need to set 'hide_empty" to false. Assuming that they have written posts, then the above code should output a list of all authors-with-posts at your site. Is it? – CK MacLeod Oct 30 '18 at 19:53
  • Thanks for replying. You are correct that a name will show using the above code if there is a post that is associated with a user (I have already tried setting hide_empty => false. However, I am trying to get the wp_list_authors() function to list authors for the default post type as well as custom post types. – Peter Oct 30 '18 at 20:26
  • well, wp_list_authors with 'hide_empty' => false should list all users with post-authoring capacities. In a mostly default WP installation, if your Message writers are listed as "Authors" under Users, they should should also come up. You could also check against or substitute the results of a get_users query. – CK MacLeod Oct 30 '18 at 21:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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