Digitalraindrops

Twenty Ten One Category

Sep 7th, 2010
287
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.19 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_Ten
  12.  * @since Twenty Ten 1.0
  13.  */
  14. get_header(); ?>
  15.    
  16.         <div id="container">
  17.             <div id="content" role="main">
  18. <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
  19.                 <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
  20.                     <div class="entry-content">
  21.                         <?php the_content(); ?>
  22.                     </div><!-- .entry-content -->
  23.                 </div><!-- #post-## -->
  24. <?php endwhile; ?>
  25.  
  26.             <?php
  27.             /*
  28.             Run the loop to output the posts.
  29.             Store the page to use later
  30.             */
  31.             global $post;
  32.             $tmp_post = $post;
  33.             //Create a query for the category
  34.             $pageslug = $post->post_name;
  35.             $catslug = get_category_by_slug($pageslug);
  36.             $catid = $catslug->term_id;
  37.             $query= 'cat=' . $catid. '&order=ASC'; query_posts($query);
  38.             //Get the lines
  39.             get_template_part( 'loop', 'category' );
  40.             //Reset our page to get the sidebar
  41.             $post = $tmp_post;
  42.             ?>
  43.             </div><!-- #content -->
  44.         </div><!-- #container -->
  45.    
  46. <?php get_sidebar(); ?>
  47. <?php get_footer(); ?>
Advertisement
Add Comment
Please, Sign In to add comment