Advertisement
Guest User

Untitled

a guest
Jan 16th, 2012
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.99 KB | None | 0 0
  1. <?php
  2. get_header();
  3. ?>
  4.  
  5.     <div class="content">
  6.    
  7.         <?php
  8.            
  9.         global $wp_query;
  10.  
  11.         // If the category name is set for this page...
  12.         // (which it will be when viewing a category on the category.php template)
  13.         $category_name = $wp_query->get( 'category_name' );
  14.         if ( isset( $category_name ) && ! empty( $category_name ) ) {
  15.                 // Now we have the category name, but we want more so we're going
  16.                 // to get the full category details using the slug name.
  17.                 $category_all = get_category_by_slug( $category_name );
  18.                
  19.                 // Now that we have all of the category details, we can safely
  20.                 // extract the category ID.
  21.                 $category_id = $category_all->cat_ID;
  22.                
  23.                 // Using the category ID we just obtained, we can get all the children
  24.                 // of this category (returned in an array).
  25.                 $category_children = get_term_children( $category_id, 'category' );
  26.                
  27.                 // And now we just need to pass this array of children to exclude
  28.                 // into $wp_query. We'll use query_posts() for this. Don't forget
  29.                 // to merge in all of the previous arguments.
  30.                 query_posts( array_merge( $wp_query->query, array(
  31.                         'category__not_in' => $category_children
  32.                 ) ) );
  33.         }
  34.        
  35.         ?>
  36.  
  37.         <?php if (have_posts()) : ?>
  38.  
  39.       <?php $post = $posts[0]; // Hack. Set $post so that the_date() works. ?>
  40.      
  41.  
  42.  
  43.         <div class="navigation">
  44.             <div class="alignleft"><?php next_posts_link(__('&laquo; Older Entries', 'kubrick')); ?></div>
  45.             <div class="alignright"><?php previous_posts_link(__('Newer Entries &raquo;', 'kubrick')); ?></div>
  46.         </div>
  47.  
  48.  
  49.         <?php while (have_posts()) : the_post(); ?>
  50.         <div <?php post_class(); ?>>
  51.                 <h2> <a href="<?php the_permalink() ?>" rel="bookmark" title="<?php printf(__('Permanent Link to %s', 'kubrick'), the_title_attribute('echo=0')); ?>"><?php the_title(); ?></a></h2>
  52.                 <small><?php the_time(__('l, F jS, Y', 'kubrick')) ?></small>
  53.  
  54.                 <div class="entry">
  55.                     <?php the_content() ?>
  56.                 </div>
  57.  
  58.                 <p class="postmetadata"><?php the_tags(__('Tags:', 'kubrick'), ', ', '<br />'); ?> <?php printf(__('Posted in %s', 'kubrick'), get_the_category_list(', ')); ?> | <?php edit_post_link(__('Edit', 'kubrick'), '', ' | '); ?>  <?php comments_popup_link(__('No Comments &#187;', 'kubrick'), __('1 Comment &#187;', 'kubrick'), __('% Comments &#187;', 'kubrick'), '', __('Comments Closed', 'kubrick') ); ?></p>
  59.  
  60.             </div>
  61. <div class="postdiv"><img src="/images/postdiv.png"></div>
  62.         <?php endwhile; ?>
  63.  
  64.         <div class="navigation">
  65.             <div class="alignleft"><?php next_posts_link(__('&laquo; Older Entries', 'kubrick')); ?></div>
  66.             <div class="alignright"><?php previous_posts_link(__('Newer Entries &raquo;', 'kubrick')); ?></div>
  67.         </div>
  68.     <?php else :
  69.  
  70.         printf("<h2 class='center'>".__("Sorry, but there aren't any posts in the %s category yet.", 'kubrick').'</h2>', single_cat_title('',false));
  71.         get_search_form();
  72.     endif;
  73. ?>
  74.  
  75.     <?php
  76.  
  77.     rewind_posts();
  78.     wp_reset_query();
  79.  
  80.     ?>
  81.  
  82.     </div>
  83.  
  84. <?php get_sidebar(); ?>
  85.  
  86. <?php get_footer(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement