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 7794181
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T22:42:31+00:00 2026-06-01T22:42:31+00:00

I have already read some info about his issue on the web, but I

  • 0

I have already read some info about his issue on the web, but I had no serious solution.
Resources I read:
http://codex.wordpress.org/The_Loop#Multiple_Loops_in_Action

http://wordpress.org/support/topic/next_posts_link-not-displays-same-posts-not-next-posts-when-using-offset – Exactly the same problem.

Now here is my code in index.php:

<!--slider-->
<div id="featured"> 
            <?php 
                // query the posts of your custom post types
                query_posts('posts_per_page=5');
                if (have_posts()) : while (have_posts()) : the_post(); ?>

<!--main body-->
    <?php 
                // query the posts of your custom post types
                query_posts('posts_per_page=5&offset=5');
                if (have_posts()) : while (have_posts()) : the_post(); ?>

When I press the next posts I get the same duplicates of the body posts.
What is the solution for this?

EDIT:
I have wrote new code:

// featured
$slider = new WP_Query(array('posts_per_page' => 5));
if ($slider->have_posts()) : while ($slider->have_posts()) : $slider->the_post();

//main:
    $p = get_query_var('paged');
                if($p >0){
                $main = new WP_Query(array('posts_per_page' => 5, 'paged'=>get_query_var('paged')));
                }else{
                $main = new WP_Query(array('posts_per_page' => 5, 'offset' => 5,'paged'=>get_query_var('paged')));
                }
                if ($main->have_posts()) : while ($main->have_posts()) : $main->the_post();

//navigation:

<div class="navigation" >
    <div class="next-posts"><div class="nextBtn2"><?php previous_posts_link(); ?></div></div>
    <div class="prev-posts"><?php next_posts_link(); ?></div>
</div>
  • 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-06-01T22:42:32+00:00Added an answer on June 1, 2026 at 10:42 pm

    You should WP_Query for secondary loop (the featured) and use query_posts for the main body.
    It works 95%
    it will break on the last page because it will try to get the (very)last 5 items but those 5 will be in the offset. 🙁
    So on the second last page you would need to hide the ‘next page’ pagination….

    $featured = new WP_Query(array('posts_per_page' => 5));
    if ($featured->have_posts()) : while ($featured->have_posts()) :
        $featured->the_post();
    
    //shouldn't be needed if u use only one query_posts but it won't hurt
    wp_reset_query();
    
    $paged = get_query_var('paged');
    $wanted_offset = 5;
    // page zero won't need a hack
    if ($paged != 0 ) {
        $post_per_page = 3;
        //$paged -1 because there is no page 1, just 0 and 2
        $offset = ($paged-1) * $post_per_page + get_query_var('posts_per_page');
    } else {
        $offset = get_query_var('posts_per_page');    
    }
    query_posts('offset=' . $offset);
    if (have_posts()) : while (have_posts()) : the_post();
    

    Let me know if it works for you too.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have already read some posts, but no one helped me with my problem.
I have already read some articles and searched on Google, but I failed to
I have read some threads regarding this and I did already take steps to
I have already read all the previous similar posts but I couldn't find a
I already asked here with no luck, but feel free to read it: http://groups.google.com/group/jquery-en/browse_thread/thread/fdf7a584b30d4bb9
I need some advice. (For those who have already read this before I have
I have already read a lot about C++ exceptions and what i see, that
I just want what my title says.I have already read all the previous similar
Possible Duplicate: What’s with the love of dynamic Languages I have already read this
I want to read .ppt files from the iPhone mail app. I have already

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.