I want to display one post per syndication source (stored in wp_postmeta).
vard_dump on $the_authors shows every source just once as it should.
After adding args to array I can get only one source with the same post multiple times.
Code:
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
That args were working when I selected this:
$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");
with
$args = array(
'author' => $bloguser->post_author,
'showposts' => 1
);
Can anyone point the problem?