Advertisement
JPry

WordPress Loop Issue change

May 24th, 2011
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.92 KB | None | 0 0
  1. <?php /* Suggestions welcome to tidy up this loop */ ?>
  2.  
  3. <?php /* Show ONE post from category 7 in div#featured */
  4.  
  5. $featured_query = new WP_Query( 'cat=7&posts_per_page=1' );
  6.  
  7. if ( $featured_query->have_posts() ) while ( $featured_query->have_posts() ) : $featured_query->the_post(); ?>
  8.     <div id="featured">
  9.         <img src="<?php echo get_post_meta($post->ID, "articleimg", TRUE); ?>" width="306px" height="365px" alt="<?php the_title(); ?>" /><?php echo $fdesc; ?>
  10.         <div class="overlay">
  11.             <p><strong>
  12.                 <a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></strong><br />
  13.                 <a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_excerpt(); ?></a>
  14.             </p>
  15.         </div>
  16.     </div>
  17.  
  18. <?php endwhile;
  19.  
  20. /* Show THREE post excerpts from all categories except category 7 in div#articles */
  21. $excerpt_query = new WP_Query( 'cat=-7' ); ?>
  22.  
  23. <div id="articles">
  24. <?php
  25.  
  26. if ( $excerpt_query->have_posts() ) :
  27.     $count = 4;
  28.     while ( $excerpt_query->have_posts() ) : $excerpt_query->the_post();
  29.         if ( $count < 7 ) { ?>
  30.         <div class="post" id="post-<?php the_ID(); ?>">
  31.             <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">
  32.             <?php the_title(); ?></a></h2>
  33.             <?php the_excerpt(); ?>
  34.             <p class="comments">
  35.                 <?php comments_popup_link('0', '1', '%'); ?>
  36.             </p>
  37.         </div>
  38.         <?php
  39.  
  40.         /*
  41.          * Show the next four post TITLES ONLY excerpts from all categories except
  42.          * category 7 in an UNORDERED LIST, still within div#articles
  43.          */
  44.  
  45.         } else if ( $count < 11 ) {
  46.             if ( $count == 7 ) {
  47.                 echo '<ul>';
  48.             } ?>
  49.             <li><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></li>
  50.             <?php
  51.             if ( $count == 10 ) {
  52.                 echo '</ul>';
  53.             }
  54.             $count++;
  55.         }
  56.     endwhile;
  57. endif; ?>
  58. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement