This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

WP Custom theme pagination breaks

By: a guest on Apr 18th, 2012  |  syntax: PHP  |  size: 2.25 KB  |  views: 17  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <?php get_header(); ?>
  2.  
  3.                 <div id="container">    
  4.                         <div id="content">
  5.  
  6.  
  7.  
  8. <?php query_posts("posts_per_page=5"); ?>
  9. <!-- Start the Loop. -->
  10.  <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
  11.  
  12.  <!-- The following tests if the current post is in category 3. -->
  13.  <!-- If it is, the div box is given the CSS class "post-cat-three". -->
  14.  <!-- Otherwise, the div box will be given the CSS class "post". -->
  15.  <?php if ( in_category('3') ) { ?>
  16.            <div class="post-cat-three">
  17.  <?php } else { ?>
  18.            <div class="post">
  19.  <?php } ?>
  20.  
  21.  <!-- Display the Title as a link to the Post's permalink. -->
  22.  <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
  23.  
  24.  <!-- Display the date (November 16th, 2009 format) and a link to other posts by this posts author. -->
  25.  <small><?php the_time('F jS, Y') ?> by <?php the_author_posts_link() ?></small>
  26.  
  27.  <!-- Display the Post's Content in a div box. -->
  28.  <div class="entry">
  29.    <?php the_content(); ?>
  30.  </div>
  31.  
  32.  <!-- Display a comma separated list of the Post's Categories. -->
  33.  <p class="postmetadata">Posted in <?php the_category(', '); ?></p>
  34.  </div> <!-- closes the first div box -->
  35.  
  36.  <!-- Stop The Loop (but note the "else:" - see next line). -->
  37.  <?php endwhile; else: ?>
  38.  
  39.  <!-- The very first "if" tested to see if there were any Posts to -->
  40.  <!-- display.  This "else" part tells what do if there weren't any. -->
  41.  <p>Sorry, no posts matched your criteria.</p>
  42.  
  43.  <!-- REALLY stop The Loop. -->
  44.  <?php endif; ?>            
  45.  
  46.  
  47. <div class="pagination">
  48. <?php
  49. global $wp_query;
  50.  
  51. $big = 999999999; // need an unlikely integer
  52.  
  53. echo paginate_links( array(
  54.     'base' => str_replace( $big, '%#%', get_pagenum_link( $big ) ),
  55.     'format' => '?paged=%#%',
  56.     'current' => max( 1, get_query_var('paged') ),
  57.     'total' => $wp_query->max_num_pages
  58. ) );
  59. ?>
  60. </div><!--END .pagination-->
  61.  
  62. <?php //Tried enabling/disabling this, but does not help
  63. //wp_reset_query();  // Restore global post data
  64. ?>
  65.  
  66.  
  67.                         </div><!-- #content -->        
  68.                 </div><!-- #container -->
  69.  
  70. <?php get_sidebar(); ?>
  71. <?php get_footer(); ?>
clone this paste RAW Paste Data