为什么WP_LIST_AUTHERS不从CPT中挑选作者?

时间:2018-10-30 作者:Peter

为什么是wp_list_authors 当我有supports 是否启用选项?从我在其他地方读到的内容来看,我似乎涵盖了所有内容,但CPT的作者拒绝透露。我试图让默认的帖子和CPT作者显示在一个统一的列表中。有人能告诉我我做错了什么吗?

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

1 个回复
SO网友:CK MacLeod

首先,“DSC”对于“order”参数是不正确的。应为“说明”

结束

相关推荐

Stop unauthorised file access

我正在开发一个插件,其中只有管理后端。有一个自定义角色,将在以后创建,现在它只是一个经理。我正在试图阻止所有人访问该页面,例如,如果你当前访问该链接,我会遇到一个问题,在我的情况下127.0.0.1/wp-content/plugins/my-plugin/templates/admin-settings.php 它将显示页面,但没有css,但我相信一切仍然正常。我做了一些研究,发现is_user_logged_in() 功能,但我不知道是否需要在每个文件中都包含此功能,或者是否有一个全局文件可以执行此操