如何从中排除按ID列出的作者:
<?php
//displays all users with their avatar and their posts (titles)
$blogusers = get_users_of_blog();
if ($blogusers) {
foreach ($blogusers as $bloguser) {
echo \'<div class="content-slider-body">\';
$user = get_userdata($bloguser->user_id);
echo \'<div class="grid col-140">\' . get_avatar( $user->ID, 128 ) . \'</div>\';
$args=array(
\'author\' => $user->ID,
\'post_type\' => \'post\',
\'post_status\' => \'publish\',
\'posts_per_page\' => 1,
\'caller_get_posts\'=> 1
);
$my_query = null;
$my_query = new WP_Query($args);
if( $my_query->have_posts() ) {
//echo \'List of Posts for \' . user->user_firstname . \' \' . $user->user_lastname;
while ($my_query->have_posts()) : $my_query->the_post(); ?>
最合适的回答,由SO网友:Tom J Nowell 整理而成
哪里$that_user_your_filtering_out
是您不想过滤掉的用户/作者ID,请对循环进行此修改
foreach ($blogusers as $bloguser) {
// modification starts here
if($bloguser->user_id == $that_user_your_filtering_out){
continue;
}
// modification ends here
echo \'<div class="content-slider-body">\';
$user = get_userdata($bloguser->user_id);