Advertisement
Guest User

wordpress category posts loop

a guest
Mar 28th, 2013
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.40 KB | None | 0 0
  1. <!-- START LOOP -->
  2.             <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
  3.                 <div class="post">
  4.                     <h1><?php the_title(); ?></h1>
  5.                     <div class="image"><img src="<?php bloginfo('template_url'); ?>/timthumb.php?src=<?php echo(types_render_field( "news-image", array( "url" => "true", "proportional" => "false" ) )); ?>&q=100&w=683" alt="<?php the_title(); ?>" title="<?php the_title(); ?>" /></div>
  6.                     <div class="content">
  7.                         <?php the_content(); ?>
  8.                     </div>
  9.                    
  10.                 </div><!-- post -->
  11.            
  12.                 <?php endwhile; else: ?>
  13.                 <p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
  14.                 <?php endif; ?>
  15.  
  16. /* HERE GOES ALL CATEGORY POSTS EXCEPT THE OPENED */
  17. <div class="custom-news">
  18.                     <div class="desc"><?php $category = get_the_category(); echo $category[0]->cat_name; ?></div>
  19.                    
  20.                         <?php $catid = the_category_ID( false ); ?>
  21.                         <?php $postCount = 1; $loop = new WP_Query( array( 'tax_query' => array(array(
  22.                                 'taxonomy' => 'category',
  23.                                 'field' => 'id',
  24.                                 'terms' => $catid
  25.                             )), 'post_type' => 'post', 'posts_per_page' => 15 ) ); if ($loop->have_posts()) { ?>
  26.    
  27.  
  28.        
  29.  
  30.        
  31.                     <?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
  32.      
  33.                     <div class="custom-item">
  34.                         <a href="<?php the_permalink(); ?>"><?php the_title (); ?></a>
  35.                     </div>
  36.                
  37.                 <?php endwhile;  ?>        
  38.                 <?php } ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement