Advertisement
Guest User

category to page

a guest
Feb 24th, 2012
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. /*
  3. Template Name: Blog
  4. */
  5. get_header(); ?>
  6.  
  7.     <div id="container">
  8.         <div id="content" role="main">
  9.  
  10.  
  11. <?php
  12. // page id 672 will get category ID 20 posts, page 670 will get category 19 posts, page 682 will get both category 19 and 20 posts
  13. if (is_page('672') ) {
  14. $cat = array(20);
  15. } elseif ( is_page('670') ) {
  16. $cat = array(19);
  17. } elseif ( is_page('682') ) {
  18. $cat = array(19,20);
  19. } else {
  20. $cat = '';
  21. }
  22.  
  23. $showposts = -1; // -1 shows all posts
  24. $do_not_show_stickies = 1; // 0 to show stickies
  25. $args=array(
  26.    'category__in' => $cat,
  27.    'showposts' => $showposts,
  28.    'caller_get_posts' => $do_not_show_stickies
  29.    );
  30.  
  31. $my_query = new WP_Query($args);
  32.  
  33. ?>
  34.  
  35. <?php if( $my_query->have_posts() ) : ?>
  36.         <?php while ($my_query->have_posts()) : $my_query->the_post(); ?>
  37.             <?php
  38.             //necessary to show the tags
  39.             global $wp_query;
  40.             $wp_query->in_the_loop = true;
  41.             ?>
  42.             <div <?php post_class() ?> id="post-<?php the_ID(); ?>">
  43.  
  44.  
  45.                 <div class="entry-post-title"><h3><?php the_title(); ?></h3></div>
  46.                 <div class="entry-content-post">
  47.                     <?php the_content('Read the rest of this entry ?'); ?>
  48.  
  49.        <small><p class="byline">Posted by <?php the_author() ?> on <?php the_time('l, F jS, Y | g:i A') ?> </p></small>
  50.  
  51.  
  52.                 <!-- <div class="entry-meta">
  53. <?php edit_post_link('Edit this entry', '<span class="entry-editlink">', '</span>'); ?>
  54.                 </div> -->
  55.  
  56.                                 </div>
  57.                 </div><!-- .post -->
  58.  
  59.  <?php /* Add a custom field with key "comments" (value is ignored) to turn on comments for a page! */ ?>
  60.  
  61. <?php if ( get_post_custom_values('comments') ) comments_template(); ?>
  62.  
  63.  
  64. <?php endwhile; ?>
  65.  
  66.     <?php else : ?>
  67.         <h2 class="center">Not Found</h2>
  68.         <p class="center">Sorry, but you are looking for something that isn't here.</p>
  69.         <?php get_search_form(); ?>
  70.  
  71.     <?php endif; ?>
  72.  
  73.         <?php comments_template( '', true ); ?>
  74.  
  75.  
  76.  
  77.             </div><!-- #content -->
  78.         </div><!-- #container -->
  79.  
  80. <?php get_sidebar(); ?>
  81. <?php get_footer(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement