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 am creating a related post article feature for my wordpress enabled site.being new to php and wordpress facing some issue. though i can user wordpress build in feature to show related post of author but since site is hosting articles of authors who don't have any profile with us and there are many such authors so when a new post is being created for the author we tend to save a custom field as author_email. so based on this we want to show all post being published of a particual author.i tried using get_posts() method

        $args = array( 'meta_key' => 'author_email', 'meta_value' => 'XYZ@XYZ.com');
        $authorposts=get_posts($args); ?>
    <div id="content">
    <span class="breadcrumbs"><a href="<?php echo get_option('home'); ?>/">Home</a> &raquo; <?php the_category(', ') ?></span>
    <?php if (count( $authorposts ) > 0) {
    foreach ( $authorposts as $post ): setup_postdata($post)            ?>
    <div id="headline_author">
          showing post tilte with image and some part of it
        <div class="clearfloat"></div>
    <?php endforeach;  ?>
    <div class="post-nav">
                <div class="previous"><?php previous_posts_link('&lsaquo; Previous Page') ?></div>
                <div class="next"><?php next_posts_link('Next Page &rsaquo;') ?></div>
                    } else {
                        echo '<p>No articles by this user</p>';

it showing the first 5 results and a link to the next page but when i click on the next page it show me that it has gone to second page as its also visible on the URL but its showing the same 5 results what it has shown in the first page. i am an idea that the query i have written on the same page is getting executed again from the beginning but not sure how to fix it. since i am using cutom fields to get posts i can use simple query to fetch post based on the limit or offse etc.

can any one help me to fix the things or can point me hw to do it in right way

thanks in advance

share|improve this question
up vote 0 down vote accepted

I think you need to tell that the query is paged.

Did you tried :

 $args = array( 'meta_key' => 'author_email', 'meta_value' => 'XYZ@XYZ.com', 'paged' => $paged);


share|improve this answer
:thanks i figuered it out, acceting your answer so that if some one faceing similar issue can benifits from it :) – Umesh Awasthi Nov 20 '11 at 8:44

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.