$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>custom post types - Why is wp_list_authors not picking up Authors from CPT's?|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

custom post types - Why is wp_list_authors not picking up Authors from CPT's?

matteradmin10PV0评论

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

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
*/
Share Improve this question edited Oct 30, 2018 at 19:26 Peter asked Oct 30, 2018 at 16:24 PeterPeter 1351 silver badge10 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

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

Post a comment

comment list (0)

  1. No comments so far