我想按名称显示所有贡献者。以下代码仅按ID提取记录和订单,但我需要按指定数据订单:
function contributors() {
global $wpdb;
$authors = $wpdb->get_results("SELECT ID, user_nicename from $wpdb->users WHERE display_name <> \'admin\' ORDER BY id DESC");
foreach ($authors as $author ) {
echo get_wp_user_avatar($author->ID);
the_author_meta(\'designation\', $author->ID);
the_author_meta(\'fullname\', $author->ID);
the_author_meta(\'company\', $author->ID);
the_author_meta(\'address\', $author->ID);
the_author_meta(\'phone\', $author->ID);
}
}
你能帮帮我吗?
谢谢
最合适的回答,由SO网友:Manoj Maurya 整理而成
我通过后得到了答案WP_User_Query
文档以下是最终查询:
$args = [
\'role__not_in\' => \'Administrator\',
\'meta_key\' => \'designation\',
\'meta_query \'=> [
\'meta_key\' => \'designation\'
],
\'orderby\' => array(
\'meta_value\'=>\'ASC\'
)
];
$my_user_query = new WP_User_Query( $args );