Advertisement
Digitalraindrops

page-onecat.php

Aug 30th, 2011
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.88 KB | None | 0 0
  1. <?php
  2. /**
  3. * Template Name: One Category
  4. */
  5. ?>
  6.  
  7. <?php get_header(); ?>
  8. <div class="span-24" id="contentwrap">
  9.     <?php get_sidebars('left'); ?>
  10.    
  11.     <!-- Start this part is the normal page section -->
  12.     <div class="span-14">
  13.         <div id="content"> 
  14.  
  15.             <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
  16.            
  17.             <?php global $post; $tmp_post = $post; // Store the Post to reset ?>
  18.            
  19.             <div class="post" id="post-<?php the_ID(); ?>">
  20.             <h2 class="title"><?php the_title(); ?></h2>
  21.                 <div class="entry">
  22.     <?php if ( function_exists("has_post_thumbnail") && has_post_thumbnail() ) { the_post_thumbnail(array(300,225), array("class" => "alignleft post_thumbnail")); } ?>
  23.                     <?php the_content('<p class="serif">Read the rest of this page &raquo;</p>'); ?>
  24.    
  25.                     <?php wp_link_pages(array('before' => '<p><strong>Pages:</strong> ', 'after' => '</p>', 'next_or_number' => 'number')); ?>
  26.    
  27.                 </div>
  28.             </div>
  29.             <?php endwhile; endif; ?>
  30.         <?php edit_post_link('Edit this entry.', '<p>', '</p>'); ?>
  31.  
  32.         <!-- End this part is the normal page section -->
  33.    
  34.         <!-- Start this part is the category posts section -->
  35.         <?php
  36.             $pageslug = $post->post_name;
  37.             $catslug = get_category_by_slug($pageslug);
  38.             $catid = $catslug->term_id;
  39.             $wp_query= null;
  40.             $wp_query = new WP_Query();
  41.             $args=array(
  42.                 'cat' => $catid,
  43.                 'paged' => $paged,
  44.             );
  45.             $wp_query->query( $args );
  46.         ?>
  47.  
  48.         <?php if ( $wp_query->have_posts() ) : ?>
  49.             <?php while ($wp_query->have_posts()) : $wp_query->the_post(); ?>
  50.                        
  51.                 <div <?php post_class() ?> id="post-<?php the_ID(); ?>">
  52.                     <h2 class="title"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
  53.                     <div class="postdate">Posted by <strong><?php the_author() ?></strong> on  <?php the_time('F jS, Y') ?> <?php if (current_user_can('edit_post', $post->ID)) { ?> | <?php edit_post_link('Edit', '', ''); } ?></div>
  54.            
  55.                     <div class="entry">
  56.                         <?php //if ( function_exists("has_post_thumbnail") && has_post_thumbnail() ) { the_post_thumbnail(array(200,160), array("class" => "alignleft post_thumbnail")); } ?>
  57.                         <?php //the_content('<strong>Read more &raquo;</strong>'); ?>
  58.                         <?php the_excerpt(); ?>
  59.                     </div>
  60.                 </div><!--/post-<?php the_ID(); ?>-->
  61.                
  62.             <?php endwhile; ?>
  63.        
  64.             <div class="navigation">
  65.                 <?php if(function_exists('wp_pagenavi')) { wp_pagenavi(); } else { ?>
  66.                 <div class="alignleft"><?php next_posts_link('&laquo; Older Entries') ?></div>
  67.                 <div class="alignright"><?php previous_posts_link('Newer Entries &raquo;') ?></div>
  68.                 <?php } ?>
  69.             </div>
  70.    
  71.             <?php
  72.             //Reset our page to get the sidebar
  73.             $post = $tmp_post;
  74.             ?>
  75.         <?php endif; ?>
  76.         <!-- End this part is the category posts section -->
  77.  
  78.         </div>
  79.     </div>
  80.    
  81. <?php get_sidebars('right'); ?>
  82.  
  83. </div>
  84. <?php get_footer(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement