Advertisement
alchymyth

more news excl current

Jul 19th, 2013
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.75 KB | None | 0 0
  1. <h2>More News</h2>
  2.             <?php // Blog post query
  3.             // store category in loc var via slug name
  4.             $category = get_category_by_slug('uncategorized');
  5.             // get category id from slug
  6.             $catID = $category->term_id;
  7.             // query posts using category id
  8.             $more_news = new WP_Query( array('cat' => $catID, 'post__not_in' => array( $post->ID ) ) );
  9.            
  10.             //display posts
  11.             if ($more_news->have_posts()) : while ($more_news->have_posts()) : $more_news->the_post(); ?>
  12.          
  13.                 <div <?php post_class(); ?>>
  14.                     <h3><?php the_title();?></h3>
  15.                    
  16.                     <div>
  17.                         <?php // Post thumbnail conditional display.
  18.                         if ( bootstrapwp_autoset_featured_img() !== false ) : ?>
  19.                             <div>
  20.                                 <a href="<?php the_permalink(); ?>" title="<?php  the_title_attribute( 'echo=0' ); ?>">
  21.                                     <?php echo bootstrapwp_autoset_featured_img(); ?>
  22.                                 </a>
  23.                             </div><!-- /inner plain div -->
  24.                            
  25.                         <?php endif; ?>
  26.                         <?php the_excerpt(); ?>
  27.                         <a href="<?php the_permalink(); ?>" title="<?php the_title();?>">
  28.                             Read full story
  29.                         </a>
  30.                         <?php if( ($more_news->current_post + 1) < ($more_news->post_count) ) { ?><div class="clear"><hr /></div><?php } ?>
  31.                     </div><!-- /plain div -->
  32.  
  33.                 </div><!-- /.post_class -->
  34.                
  35.             <?php // end of blog post loop and reset query
  36.             endwhile; endif; wp_reset_postdata(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement