我想显示每个联合发布一个帖子(存储在wp_postmeta中)。 $ the_authors上的vard_dump只显示一次所有来源。 将args添加到数组后,我只能多次获得一个具有相同帖子的源。
代码:
function distinct_user(){
global $wpdb;
$the_authors = $wpdb->get_results( "SELECT DISTINCT meta_value FROM $wpdb->postmeta WHERE meta_key ='syndication_source'");
//echo '<pre>';
return($the_authors);
//echo '</pre>';
}
$blogusers = distinct_user();
if ($blogusers) {
foreach ($blogusers as $bloguser) {
$args = array(
'author' => $bloguser->meta_value,
'showposts' => 1
);
$my_query = new WP_Query($args);
if( $my_query->have_posts() ) {
while ($my_query->have_posts()) : $my_query->the_post(); ?>
//rest of the template
当我选择这个时,args正在工作:
$the_authors = $wpdb->get_results( "SELECT DISTINCT post_author FROM $wpdb->posts WHERE post_status='publish' AND post_type='post' AND post_author !='1' ORDER BY post_date DESC LIMIT 0,1000");
与
$args = array(
'author' => $bloguser->post_author,
'showposts' => 1
);
有人能指出问题吗?