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

The Archive Base Latest Questions

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

I’m trying to setup a loop in WordPress that will show all posts from

  • 0

I’m trying to setup a loop in WordPress that will show all posts from one category, which is working just fine, however my problem is that my ‘next_posts_link’ and ‘previous_posts_link’ doesn’t work. They navigate between pages just fine but the results are the same as the first page all the time.

<?php get_header(); ?>

<div id="main" role="main">

<?php
if (is_home()) {
query_posts("cat=-6");} //Exclude work posts (cat 6) from the news page
?>

<div class="inner">

<h1><?php trim(wp_title("")); ?></h1>

<?php include ('sidebartwo.php'); ?>

<section class="main-wrap twocol news">

<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>

<article class="box-style">

<time><?php the_time('M d') ?><span><?php the_time('Y') ?></span></time>

<h2><a href="<?php the_permalink()?>" title="<?php the_title(); ?>"><?php the_title(); ?>
</a></h2>

<?php the_content(''); ?>

</article>

<?php endwhile; ?>                              

<div class="next-prev-wrap">

<!-- This is what isn't working properly -->
<span class="next"><?php next_posts_link( 'Older posts', $post->max_num_pages ); ?></span>
<span class="prev"><?php previous_posts_link( 'Newer posts', $post->max_num_pages ); ?>
<!-- /end -->

</span>

</div>

</section>      

<?php endif; ?>

</div> <!-- /inner -->

</div> <!-- /main -->

<?php get_footer(); ?>

I don’t think I’m using the right syntax, in fact according to the WP codex page, I don’t even think my next/prev links are able to work the way I want it to. How should I approach this?

  • 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-28T21:26:05+00:00Added an answer on May 28, 2026 at 9:26 pm

    Fixed myself. This post is now resolved. After much (and I mean much) Googling, I found this article which solved my problem: http://www.dynamicwp.net/articles-and-tutorials/pagination-problem-when-excluding-certain-category-from-blog-main-page/

    For reference my new code now looks like this:

    <?php get_header(); ?>
    
    <div id="main" role="main">
    
    <?php
    if (is_home()) {
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    query_posts("cat=-6&paged=$paged");
    }
    ?>
    
    <div class="inner">
    
    <h1><?php trim(wp_title("")); ?></h1>
    
    <?php include ('sidebartwo.php'); ?>
    
    <section class="main-wrap twocol news">
    
    <?php if (have_posts()) : ?>
    <?php while (have_posts()) : the_post(); ?>
    
    <article class="box-style">
    
    <time><?php the_time('M d') ?><span><?php the_time('Y') ?></span></time>
    
    <h2><a href="<?php the_permalink()?>" title="<?php the_title(); ?>"><?php the_title(); ?></a>   </h2>
    
    <?php the_content(''); ?>
    
    </article>
    
    <?php endwhile; ?>                              
    
    <div class="next-prev-wrap">
    
    <span class="next"><?php next_posts_link( 'Older posts', $post->max_num_pages ); ?></span>
    <span class="prev"><?php previous_posts_link( 'Newer posts', $post->max_num_pages ); ?></span>
    
    </div>
    
    </section>      
    
    <?php endif; ?>
    
    </div> <!-- /inner -->
    
    </div> <!-- /main -->
    
    <?php get_footer(); ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a text area in my form which accepts all possible characters from
I am trying to understand how to use SyndicationItem to display feed which is
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I need a function that will clean a strings' special characters. I do NOT
I'm trying to create an if statement in PHP that prevents a single post
I am trying to loop through a bunch of documents I have to put
I have a bunch of posts stored in text files formatted in yaml/textile (from
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm working with an upstream system that sometimes sends me text destined for HTML/XML

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.