Jump to content
Stef's Coding Community
straightryder

WP Pagenation not working

Recommended Posts

Helloo there, question if someone would be of assistance:

 

I'm unable to get my pagenation working in a custom Wordpress theme. I've tried the default theme and pagenation works there, so I know im doing something wrong. What happens is when i click to go back or forward nothing happens. It just stays on the same page, with the same postings. I attempted to deactivate all pluggins.... that didn't seem to help *cause* pagenation worked when the default theme with the plugins activated. Hope I'm not confusing anyone.

 

Cheers.

 

Below is a snippet of the code:

 

 

<div id="main-content" >

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

 

<div class="blogpost">

 

<?php if (in_category('4')) continue; ?>

 

<?php the_post_thumbnail(array(180,144), array ('class' => '.thumbnail')); ?>

<div class="post-title">

<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>

<span class="post-cat"><?php the_tags('Price Range: '); ?></span> <span class="post-comments">City Listing: <?php the_category(', ') ?></span>

</div>

 

<div class="entry">

<?php the_excerpt(20); ?>

</div>

 

</div>

 

<?php endwhile; ?>

 

<div class="navigation">

<span class="previous-entries"><?php next_posts_link('Older Entries') ?></span>

<span class="next-entries"><?php previous_posts_link('Newer Entries') ?></span>

</div>

 

<?php else : ?>

 

<h2>Not Found</h2>

<p>Sorry, but you are looking for something that isn't here.</p>

 

<?php endif; ?>

Share this post


Link to post
Share on other sites

Everything else in the page is working fine? What do the previous/next links to? I understand you say they aren't working, but what URL do you get when you view the site in a browser?

Share this post


Link to post
Share on other sites

/projects/ <--- the page the posts are listed on

 

 

then when i click "Previous" i get...

 

/projects/page/2/ <-- this is the following url... the older posts don't show.

 

There are a total of 7 posts but the page will only display the same five postings.

Share this post


Link to post
Share on other sites

Okay, here's the full index.php file.

 

 

<?php get_header(); ?>

 

<?php include (TEMPLATEPATH . '/featureslider.php'); ?>

 

<?php include (TEMPLATEPATH . '/searchform.php'); ?>

 

<div style="background:none;" class="main-dive-image"></div>

 

<?php get_sidebar(); ?>

 

<div id="main-content" >

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

 

<div class="blogpost">

 

<?php if (in_category('4')) continue; ?>

 

<div class="thumbnail"> <?php the_post_thumbnail(array(180,144), array ('class' => '.thumbnail')); ?></div>

<div class="post-title">

<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>

<span class="post-cat"><?php the_tags('Price Range: '); ?></span> <span class="post-comments">City Listing: <?php the_category(', ') ?></span>

</div>

 

<div class="entry">

<?php the_excerpt(20); ?>

</div>

 

 

</div>

 

<?php endwhile; ?>

 

<div class="navigation">

<span class="previous-entries"><?php next_posts_link('Older Entries') ?></span>

<span class="next-entries"><?php previous_posts_link('Newer Entries') ?></span>

</div>

 

<?php else : ?>

 

<h2>Not Found</h2>

<p>Sorry, but you are looking for something that isn't here.</p>

 

<?php endif; ?>

 

</div>

 

</div>

<div style="clear:both;"></div>

 

</div>

 

<?php get_footer(); ?>

Share this post


Link to post
Share on other sites

What happens if you remove the

 

<?php if (in_category('4')) continue; ?>

line? That syntax looks a bit strange to me, though maybe it's something to do with PHP that I haven't run into before. After removing that line, do the links work?

 

If not... I'm not really sure what to tell you. You can always zip up your theme and email it to me, and I can take a look at it as a whole (ben [at] falkencreative.com).

Share this post


Link to post
Share on other sites

It took me a little while to figure it out, but I got it eventually. Basically, this line in your sidebar.php file

 

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

is affecting your main loop. You can fix this in one of two ways:

 

1 - using a dynamic, widget based sidebar (my personal preference) since there are built in widgets for all of the sidebar items, and it will make sidebar customization easier in the future.

 

2 - alternately, you can add

 

<?php wp_reset_query(); ?>

to the bottom of your sidebar.php file, which will reset the query and allow the main loop to work normally.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...