Advertisement
Digitalraindrops

2011 One Category Template

Aug 30th, 2011
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.42 KB | None | 0 0
  1. <?php
  2. /**
  3.  * Template Name: One Category
  4.  *
  5.  * A custom page template Page Name = Category Name .
  6.  *
  7.  * The "Template Name:" bit above allows this to be selectable
  8.  * from a dropdown menu on the edit page screen.
  9.  *
  10.  * @package WordPress
  11.  * @subpackage Twenty_Eleven
  12.  * @since Twenty Eleven 1.0
  13.  */
  14.  
  15. get_header(); ?>
  16.  
  17.         <div id="primary">
  18.             <div id="content" role="main">
  19.  
  20.                 <?php the_post(); global $post; $tmp_post = $post; ?>
  21.                 <?php get_template_part( 'content', 'page' ); ?>
  22.                 <?php
  23.                 /*
  24.                 Run the loop to output the posts.
  25.                 Store the page to use later
  26.                 */
  27.                
  28.                 //Create a query for the category
  29.                 global $cat_detail;
  30.                 $pageslug = $post->post_name;
  31.                 $catslug = get_category_by_slug($pageslug);
  32.                 $catid = $catslug->term_id;
  33.                 $detail = $cat_detail[$catid];
  34.                 $asc = ($detail['asc']);
  35.                 $query= 'cat=' . $catid. '&order=' .$asc; query_posts($query);
  36.                 //Get the lines
  37.                 ?>
  38.                 <?php if ( have_posts() ) : ?>
  39.                     <?php twentyeleven_content_nav( 'nav-above' ); ?>
  40.                     <?php while ( have_posts() ) : the_post(); ?>
  41.                         <?php get_template_part( 'content', 'onecat' ); ?>
  42.                     <?php endwhile; ?>
  43.                 <?php twentyeleven_content_nav( 'nav-below' ); ?>
  44.                 <?php endif;
  45.                 //Reset our page to get the sidebar
  46.                 $post = $tmp_post;
  47.                 ?>
  48.                 <?php comments_template( '', true ); ?>
  49.  
  50.             </div><!-- #content -->
  51.         </div><!-- #primary -->
  52.  
  53. <?php get_footer(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement