Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6818095
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:08:04+00:00 2026-05-26T21:08:04+00:00

i am creating a related post article feature for my wordpress enabled site.being new

  • 0

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

<?php 
        $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>
    </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>
    </div>
   <?php
                    } else {
                        echo '<p>No articles by this user</p>';
                    }       
                    ?>
</div>

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T21:08:04+00:00Added an answer on May 26, 2026 at 9:08 pm

    I am not word-press/php expert just started learning about it. it seems that you have not set the paged global variable by which it can track the page number.

    you need to do something like this.

    $post_per_page = get_option('posts_per_page');
                if (!is_paged()) {
                $custom_offset = 0;
                } else {
                $custom_offset = $post_per_page*($paged-1); 
                }
                $args = array( 'meta_key' => 'author_email', 'meta_value' => xyz@xyz.com' ,'numberposts' => $post_per_page,'offset' => $custom_offset);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i'm new related to creating php class's and objects... I'm trying to make a
This post is related to my Previous Post . There I was creating the
In a related question I asked about creating a generic container. Using polymorphic templates
I've seen several questions/answers related to entirely creating a button in code, but not
(First question related to iPhone development, so apologies for sounding off-track.) I'm creating a
I am struggling with a creating a query. It is related to a large
Original question has been answered. Update addresses related question raised in comments. Original post:
I am creating a Doxygen document for my project. Recently, I have grouped related
I am searching for some sample interface or design for creating a Share &
Hi I am creating a wordpress custom page theme, I have included the code.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.