Advertisement
Guest User

Untitled

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