Advertisement
Guest User

Untitled

a guest
Dec 9th, 2012
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.09 KB | None | 0 0
  1. <?php
  2. /*
  3. Template Name: Page Of Posts with Custom Fields
  4. */
  5.  
  6. get_header(); ?>
  7. <div id="primary-custom">
  8. <div id="content" class="narrowcolumn">
  9. <?php
  10. if (is_page() ) {
  11. $category = get_post_meta($posts[0]->ID, 'category', true);
  12. }
  13. if ($category) {
  14. $cat = get_cat_ID($category);
  15. $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
  16. $post_per_page = 4; // -1 shows all posts
  17. $do_not_show_stickies = 1; // 0 to show stickies
  18. $args=array(
  19. 'category__in' => array($cat),
  20. 'orderby' => 'date',
  21. 'order' => 'DESC',
  22. 'paged' => $paged,
  23. 'posts_per_page' => $post_per_page,
  24. 'ignore_sticky_posts' => $do_not_show_stickies
  25. );
  26. $temp = $wp_query; // assign orginal query to temp variable for later use
  27. $wp_query = null;
  28. $wp_query = new WP_Query($args);
  29. if( have_posts() ) :
  30. while ($wp_query->have_posts()) : $wp_query->the_post(); ?>
  31. <div <?php post_class() ?> id="post-<?php the_ID(); ?>">
  32.  
  33.  
  34. <h1 class="entry-title"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h1>
  35. <small><?php the_time('F jS, Y') ?> <!-- by <?php the_author() ?> --></small>
  36.  
  37. <div class="entry">
  38. <?php global $more;
  39. $more = 0; ?>
  40. <?php the_content('Read the rest of this entry »'); ?>
  41. </div>
  42. <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>
  43. </div>
  44. <?php endwhile; ?>
  45. <div class="navigation">
  46. <div class="alignleft"><?php next_posts_link('« Older Entries') ?></div>
  47. <div class="alignright"><?php previous_posts_link('Newer Entries »') ?></div>
  48. </div>
  49. <?php else : ?>
  50. <h2 class="center">Not Found</h2>
  51. <p class="center">Sorry, but you are looking for something that isn't here.</p>
  52. <?php get_search_form(); ?>
  53.  
  54. <?php endif;
  55.  
  56. $wp_query = $temp; //reset back to original query
  57.  
  58. } // if ($category)
  59. ?>
  60. </div>
  61. </div>
  62. <?php get_sidebar(); ?>
  63. <?php get_footer(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement