我有一个自定义帖子类型(“新闻”)和一个客户用户角色(“朋友”)。
我怎样才能得到“朋友”写的最后一条“新闻”?
我有一个自定义帖子类型(“新闻”)和一个客户用户角色(“朋友”)。
我怎样才能得到“朋友”写的最后一条“新闻”?
我会尝试以下方法(未测试)
<?php
$friends = get_users( array( \'role\' => \'friends\' ) );
$friend_ids = array();
foreach( $friends as $friend )
$friend_ids[] = $friend->ID;
$news = new WP_Query( array( \'author\' => implode( \',\', $friend_ids ), \'post_type\' => \'news\', \'paged\' => get_query_var(\'paged\') ) );
?>
注意:“friends”是角色ID,而不是好名字。然后按正常方式使用循环:<?php if ( $news->have_posts() ) : while ( $news->have_posts() ) : $news->the_post(); ?>
...
<?php endwhile; endif; ?>
<?php wp_reset_postdata(); ?>
希望这能奏效:)我正在尝试向我的主题函数添加代码。php在仪表板用户中显示使用Cimy用户额外字段插件创建的字段。php。我知道我需要使用manage\\u users\\u列,但除此之外,我陷入了困境。有谁对这个插件足够熟悉,可以帮助我获得要显示的正确字段?