Advertisement
Guest User

Untitled

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