ahsanaltaf
Member
Posted 3 years ago #
HI as the topic i need to do that.
So i searched around and found
<?php query_posts('cat=-1'); ?>
It works fine , but now the problem is with the navigation (i.e next page ,previous page ) on the index.
The problem is that i have 5posts in the cat=1 and 10 posts in rest of the categories and im using "Blog pages show at most=5posts" so i should have 2 previous pages right . But when ever i click previous page it shows the same 5 posts(i.e the recent 5 ones ) on the next page and the next page ??
It may be difficult to understand my problem but im hoping for the best.
Regards.
Hi
This will solve your problem
<?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
query_posts("cat=-1&paged=$paged"); ?>
ahsanaltaf
Member
Posted 3 years ago #
Where do i put it? before the loop or after?
PS it dosnt work with both ,so here is the code
<?php get_header(); ?>
<div id="mainpost2">
<h1>Latest News:</h1>
<?php $recent = new WP_Query("cat=1&showposts=1"); while($recent->have_posts()) : $recent->the_post();?>
<a href="<?php the_permalink() ?>" rel="bookmark">
<?php the_title(); ?>
</a>
<?php endwhile; ?>
</div>
<br />
<?php
// Get posts excluding category id 1
query_posts('cat=-1');
// the Loop
while (have_posts()) : the_post();
// the content of the post
the_content;
endwhile;
?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<div class="postinfo">
<?php include(TEMPLATEPATH.'/imagevalues.php'); ?>
<a href="<?php echo $url; ?>" class="thumpre" rel="<?php echo $image1; ?>" title=""><img src="<?php echo $image; ?>" alt="<?php the_title(); ?>" /></a>
<?php the_content ?>
<div class="contentCenter">
<h1><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1>
<div class="right"> <h1><small><a href="<?php the_permalink(); ?>#comments"> (<?php comments_number('0','1','%'); ?>)</a></small></h1> </div> </div>
</div>
<?php endwhile; ?>
<?php else : ?>
<div class="postinfo3">
<h2 class="pagetitle">Not Found</h2>
<p>Sorry, but you are looking for something that isn't here.</p>
</div>
<?php endif; ?>
<div class="navigation">
<div class="alignleft"><?php next_posts_link('« Older Entries') ?></div>
<div class="alignright"><?php previous_posts_link('Newer Entries »') ?></div>
</div>
</div>
<?php get_footer(); ?>
Thanks.
Hi
In your code above, change this
<?php
// Get posts excluding category id 1
query_posts('cat=-1');
// the Loop
while (have_posts()) : the_post();
// the content of the post
the_content;
endwhile;
?>
to this
<?php
// Get posts excluding category id 1
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
query_posts("cat=-1&paged=$paged");
// the Loop
while (have_posts()) : the_post();
// the content of the post
the_content;
endwhile;
?>
ahsanaltaf
Member
Posted 3 years ago #
Thanks alot stvwlf.
I really appreciate it. It totally solved my problem.
Regards.