Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

I am having Page-navigation-problem WordPress

  • SOLVED

Hi everyone, please I need help with this.

I am having Page-navigation-problem, when i go to page 2, 3, 4 and so on the results are same with blog page.


http://www.HireYourVirtualAssistant.com/blog

is the same as

http://www.hireyourvirtualassistant.com/blog/page/2/
http://www.hireyourvirtualassistant.com/blog/page/3/

and so on.

I don't know what to do, kinda confused too.

Please help

Answers (4)

2010-07-10

Xavier Faraudo answers:

Normally, this problem is related to badly constructed query.
You must pass the get_query_var( 'paged' ) arg as the paged arg of your query, something like this:
$posts = query_posts( $query_string . '&paged=' . get_query_var( 'paged' ) );

Or also

$posts = query_posts( array( 'paged' => get_query_var( 'paged' ) ) );

It'd help a lot if you wrote the code for the Loop present in your Page, index.php or home.php template.
It's quite possible that you should pass the posts_per_page arg.

Without knowing a little more about your theme and the code of the template, I'm afraid I cannot help much more.


Owen E comments:

I have included my whole index.php code below. Please let me know where to put the code

<?php get_header(); ?>
<div id="breadcrumbs" style="font-size:1px;"></div>
<div class="hbar" style="margin-bottom:10px;">

<div style="width:250px;height:80px;float:left;">
<a href="http://www.hireyourvirtualassistant.com/faqs/hire-your-virtual-assistant/"><img src="http://www.hireyourvirtualassistant.com/wp-content/themes/theme/images/rbutton2.gif" border="0" /></a> </div>

<div style="width:200px;height:80px; float:left;border-left:#3399CC 3px solid;border-right:#3399CC 3px solid;" class="rbar" >
<div align="center" class="supp2">
<h3 align="center" style="font-family:Arial, Helvetica, sans-serif;color:#FF0000;margin-top:3px;font-size:12px;">NEED HELP? </h3>

<!--<img src="http://www.hireyourvirtualassistant.com/wp-content/themes/theme/images/chat.jpg" />-->
<!-- BEGIN ProvideSupport.com Graphics Chat Button Code -->
<div id="cib0t1" style="z-index:100;position:absolute"></div>
<div id="scb0t1" style="display:inline"></div><div id="sdb0t1" style="display:none"></div>
<script type="text/javascript">
var seb0t1=document.createElement("script");
seb0t1.type="text/javascript";
var seb0t1s=(location.protocol.indexOf("https")==0?"https":"http")+"://image.providesupport.com/js/propertylion/safe-standard.js?ps_h=b0t1&ps_t="+new
Date().getTime();

setTimeout("seb0t1.src=seb0t1s;document.getElementById('sdb0t1').appendChild(seb0t1)",1);
</script><noscript><div style="display:inline">
<a href="http://www.providesupport.com?messenger=propertylion">Live Customer Service</a></div>
</noscript>
<!-- END ProvideSupport.com Graphics Chat Button Code -->

</div>
</div>

<div style="width:400px;height:80px;float:left;margin-left:28px;">
<h2 class="chere" style="margin-top:17px;">Let us help you make your business efficient!!</h2>
</div>


</div>
<div id="upper" class="clearfloat">

<div id="lead" class="clearfloat">

<div class="left">

<?php
//Interacts with control panel to determine lead category
$bm_categories = get_categories('hide_empty=0');
$mim_feature = get_settings( "mim_feature" );
if( $mim_feature == 0 ) { $mim_feature = $bm_categories[ 0 ]->cat_ID; }
query_posts( 'showposts=1&cat=' . $mim_feature );
while (have_posts()) : the_post();
?>


<?php

$values = get_post_custom_values("Image");

if (isset($values[0])) {
?>
<a href="<?php the_permalink() ?>" rel="bookmark"><img src="<?php echo bloginfo('template_url'); ?>/scripts/timthumb.php?src=/<?php
$values = get_post_custom_values("Image"); echo $values[0]; ?>&amp;w=200&amp;h=210&amp;zc=1" alt="<?php the_title(); ?>" /></a>
<?php } ?>


</div>

<div class="right">
<h3><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a>
<span class="commentcount">(<?php comments_popup_link('0', '1', '%'); ?>)</span></h3>
<div class="date"><?php the_date(); ?> &bull; Category: <?php the_category(', ') ?></div>
<div class="bigger"><?php the_excerpt(); ?></div>
<a href="<?php the_permalink() ?>" rel="bookmark" id="fullstory"><?php the_title(); ?></a>
<?php endwhile; ?>
</div>

</div><!--END LEAD-->


<div id="recent">
<h3>Recent <span>Stories</span></h3>
<ul>
<?php query_posts('showposts=5'); ?>
<?php while (have_posts()) : the_post(); ?>
<li><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></li>
<?php endwhile; ?>
</ul>
</div>
</div><!--END UPPER-->

<div class="clearfloat" style="border: 3px solid #3399CC; background-color: #FFFFFF;">

<?php get_sidebar(); ?>

<div id="content" style="padding-top:30px;">

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

<div class="post" id="post-<?php the_ID(); ?>" style="margin-bottom:30px;">

<div class="commentcount" style="font-size:10px;"><?php comments_popup_link('0', '1', '%'); ?></div>
<div style="width:350px;">
<h4 style="font-size:16px;"><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></div></h4>
<!--<p class="meta">Posted on <?php the_time('F jS, Y') ?> by <?php the_author() ?> &nbsp;|&nbsp; <?php edit_post_link('Edit', '', ' &nbsp;|&nbsp; '); ?> <?php comments_popup_link('No Comments &#187;', '1 Comment &#187;', '% Comments &#187;'); ?></p>-->
<div class="entry">
<?php the_content(); ?>
</div>

</div>

<?php endwhile; ?>

<div class="navigation">
<?php if(function_exists('wp_pagenavi')) { wp_pagenavi(); }
?>
</div>




</div><!--END CONTENT-->

<?php include("ads.php"); ?>
</div><!--END STRIPES-->


<?php get_footer(); ?>


Xavier Faraudo comments:

Look for this piece:
<?php query_posts('showposts=5'); ?>

It should be:

<?php query_posts( array( 'posts_per_page' => get_query_var( 'posts_per_page' ), 'paged' => get_query_var( 'paged' ) ) ); ?>

The param/arg showposts is deprecated, it's been substituted by posts_per_page.
This forced 5 posts per page, whatever you set in the settings. With this fix, it will take the value you set in the settings.


Xavier Faraudo comments:

Corrigenda: I wrote "take the value you set in the settings" when it's actually the value passed by the query var. If the query var for the number of posts is empty, it'll take the option value. Anyway, you can specify it to be 'posts_per_page' => get_option( 'posts_per_page' ) to take directly the option value, or just 5 for 5 posts (or whatever other number).
Sorry for this mistake, I was thinking too much in the paged issue.


Xavier Faraudo comments:

Also, as for why you should NOT, NEVER use "showposts", you can look at [LINK href="http://lists.automattic.com/pipermail/wp-hackers/2010-July/033082.html"]this thread in the wp-hackers list[/LINK].
That code from weblogtoolscollection is severely outdated and you should not use it.


Owen E comments:

You suggestion worked. thanks

2010-07-10

Guillermo Sornoza answers:

Hi.

You must replace the line

query_posts( 'showposts=1&cat=' . $mim_feature );

with

query_posts(
array_merge(
array('cat' => $mim_feature,'showposts' => 1),
$wp_query->query
)


Owen E comments:

I tried your suggestion and it did not work. please advice


Owen E comments:

I also made use of your code to and it worked in conjuction with Xavier's

2010-07-10

Roberto Mas answers:

under the admin panel under settings > Reading >  specify wich is your post page Posts page:


Owen E comments:

I did that already and that is not the solution


Roberto Mas comments:

read this it should help you http://weblogtoolscollection.com/archives/2008/04/19/paging-and-custom-wordpress-loops/

2010-07-10

Darrin Boutote answers:

Your biggest problem is that you have 3 main post queries running on the same page:

<?php

//Interacts with control panel to determine lead category

$bm_categories = get_categories('hide_empty=0');

$mim_feature = get_settings( "mim_feature" );

if( $mim_feature == 0 ) { $mim_feature = $bm_categories[ 0 ]->cat_ID; }

query_posts( 'showposts=1&cat=' . $mim_feature );

while (have_posts()) : the_post();

?>



<div id="recent">

<h3>Recent <span>Stories</span></h3>

<ul>

<?php query_posts('showposts=5'); ?>

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

<li><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></li>

<?php endwhile; ?>

</ul>

</div>



<div id="content" style="padding-top:30px;">



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



<div class="post" id="post-<?php the_ID(); ?>" style="margin-bottom:30px;">



<div class="commentcount" style="font-size:10px;"><?php comments_popup_link('0', '1', '%'); ?></div>



When you click on a page link, only the first query is getting invoked.


Owen E comments:

Please advice on what to do? You have the original code please send me your modification using your suggestion. thanks