1. <?php
  2. /*
  3. Template Name: PageOfPosts
  4. */
  5.  
  6. get_header(); ?>
  7.  
  8. <div id="content" class="narrowcolumn">
  9.  
  10. <?php
  11. if (is_page() ) {
  12. $category = get_post_meta($posts[0]->ID, 'category', true);
  13. }
  14. if ($category) {
  15.   $cat = get_cat_ID($category);
  16.   $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
  17.   $post_per_page = 4; // -1 shows all posts
  18.   $do_not_show_stickies = 1; // 0 to show stickies
  19.   $args=array(
  20.     'category__in' => array($cat),
  21.     'orderby' => 'date',
  22.     'order' => 'DESC',
  23.     'paged' => $paged,
  24.     'posts_per_page' => $post_per_page,
  25.     'caller_get_posts' => $do_not_show_stickies
  26.   );
  27.   $temp = $wp_query;  // assign orginal query to temp variable for later use  
  28.   $wp_query = null;
  29.   $wp_query = new WP_Query($args);
  30.   if( have_posts() ) :
  31.         while ($wp_query->have_posts()) : $wp_query->the_post(); ?>
  32.         <div <?php post_class() ?> id="post-<?php the_ID(); ?>">
  33.         <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
  34.         <small><?php the_time('F jS, Y') ?> <!-- by <?php the_author() ?> --></small>
  35.         <div class="entry">
  36.           <?php the_content('Read the rest of this entry »'); ?>
  37.         </div>
  38.         <p class="postmetadata"><?php the_tags('Tags: ', ', ', '<br />'); ?> Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?>  <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?></p>
  39.       </div>
  40.     <?php endwhile; ?>
  41.     <div class="navigation">
  42.       <div class="alignleft"><?php next_posts_link('« Older Entries') ?></div>
  43.       <div class="alignright"><?php previous_posts_link('Newer Entries »') ?></div>
  44.     </div>
  45.   <?php else : ?>
  46.  
  47.         <h2 class="center">Not Found</h2>
  48.         <p class="center">Sorry, but you are looking for something that isn't here.</p>
  49.         <?php get_search_form(); ?>
  50.  
  51.     <?php endif;
  52.    
  53.     $wp_query = $temp;  //reset back to original query
  54.    
  55. }  // if ($category)
  56. ?>
  57.  
  58.     </div>
  59.  
  60. <?php get_sidebar(); ?>
  61.  
  62. <?php get_footer(); ?>