WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to show in latest posts widget only posts by admin (now its showing latests posts by all suers). How I can do it ? via wp query ? Thanks :)

<?php // setup the query
                    $cust_loop = new WP_Query($args); 
                    if ($cust_loop->have_posts()) : while ($cust_loop->have_posts()) : $cust_loop->the_post(); $postcount++;
                        // if we're sorting by rating and this item does not have a rating, hide it
                        $rating = get_post_meta(get_the_ID(), "Rating", $single = true); 
                        if(($rating && $feedsort=="meta_value") || ($feedsort!="meta_value")) {                                     
                            $ratings = con_setup_rating($rating); //setup the ratings array


                            <?php con_show_rating($ratings[0], $ratings[1], $ratings[2]); // show the stars or hearts ?>    

                            <a class="post-title" href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a>                                              


                    <?php } ?>

                <?php endwhile; 
                wp_reset_query(); ?>
share|improve this question

You need to add an author parameter to the query that is creating $cust_loop. You didn't post that part of your code but something like:

$cust_loop = new WP_Query( 'author=123' );


$cust_loop = new WP_Query( 'author_name=rami' );

Note: Both of those taken (almost) straight from the Codex paged for WP_Query.

share|improve this answer
Thanks :) It worked, but there is problem. I had settings that only 6 posts show in sidebar, but when I insert $cust_loop = new WP_Query( 'author=123' ); and widget settings don't work anymore. Now it shows 9 posts, but i want 6 :D – Product Investigation Nov 3 '12 at 11:11

Ok, thanks now its working :)

$cust_loop = new WP_Query(array('author_name' => 'admin', 'posts_per_page' => 6)); 
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.