straightryder Posted March 30, 2011 Report Posted March 30, 2011 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; ?> Quote
falkencreative Posted March 30, 2011 Report Posted March 30, 2011 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? Quote
straightryder Posted March 31, 2011 Author Report Posted March 31, 2011 /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. Quote
falkencreative Posted March 31, 2011 Report Posted March 31, 2011 I think you'll need to post the full code from that page (I'm assuming it's index.php?). My guess is that you are using some sort of custom query that doesn' take into account pagination? If so, this might be useful: http://weblogtoolscollection.com/archives/2008/04/19/paging-and-custom-wordpress-loops/ Quote
straightryder Posted March 31, 2011 Author Report Posted March 31, 2011 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(); ?> Quote
straightryder Posted March 31, 2011 Author Report Posted March 31, 2011 Could it be the query highlighted in red... you think? Quote
falkencreative Posted March 31, 2011 Report Posted March 31, 2011 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). Quote
falkencreative Posted March 31, 2011 Report Posted March 31, 2011 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. Quote
straightryder Posted March 31, 2011 Author Report Posted March 31, 2011 How many beers do i owe you now? lol Thanks - it worked like a charm. Much appreciated Ben!! Quote
Recommended Posts
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.