Title: Difficult Conditional Loop Problems
Last modified: August 19, 2016

---

# Difficult Conditional Loop Problems

 *  [greg9885](https://wordpress.org/support/users/greg9885/)
 * (@greg9885)
 * [16 years, 2 months ago](https://wordpress.org/support/topic/difficult-conditional-loop-problems/)
 * I’ve been looking all over the forums and the web and I can’t figure out what
   to do. The loop is getting confusing because I’ve looked at it for so long.
 * Here’s what I’m trying to accomplish with my index.php
 * – **1 Featured Post** that only shows on first (home page) page which is styled
   completely different and has extra content than just a regular post (ie: can’t
   use “sticky” feature)
    – **8 More Posts.** Each will be tagged as 1 of three 
   things (so three different styles of posts). So I’d like the loop to say IF TAGGED
   THIS TYPE OF POST THEN SHOW THIS, IF TAGGED THIS TYPE OF POST THEN SHOW THIS,
   AND IF TAGGED THIS TYPE OF POST THEN SHOW THIS.
 * Here’s the code I’m workin’ with…
 *     ```
       <?php get_header(); ?>
   
       <?php if ( is_home() and !is_paged() ) { ?>
   
       <!--FEATURED -->
       <?php query_posts('tag=featured&showposts=1'); ?>
       <?php while (have_posts()) : the_post(); ?>
       <!--CONTENT -->
       <?php endwhile; ?>
       <!--END FEATURED -->
       <?php } ?>
   
       <!--LOOP TO GET 8 POSTS-->
       <?php $page = (get_query_var('paged')) ? get_query_var('paged') : 1; query_posts("offset=1&showposts=8&paged=$page"); ?>
       <?php if (have_posts()) : while (have_posts()) : the_post(); ?>    
   
       <!------------ I DON'T KNOW WHAT TO PUT HERE ------------>
   
       <?php endwhile; ?>
       <!--END LOOP TO GET 8 POSTS-->
   
       <?php else : ?>
   
       	<h2>Not Found</h2>
       	<p>Sorry, but you are looking for something that isn't here.</p>
       	<?php get_search_form(); ?>
   
       <?php endif; ?>
   
         </div>
   
       <?php get_footer(); ?>
       ```
   
 * Help would be greatly appreciated. Thank you!!

Viewing 5 replies - 16 through 20 (of 20 total)

[←](https://wordpress.org/support/topic/difficult-conditional-loop-problems/?output_format=md)
[1](https://wordpress.org/support/topic/difficult-conditional-loop-problems/?output_format=md)
2

 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [16 years, 2 months ago](https://wordpress.org/support/topic/difficult-conditional-loop-problems/page/2/#post-1445272)
 * could you be more specific?
    is that on the front page? i can’t identify any 
   post with extra padding there.
 * the following code should give every fourth post a extra class:
 *     ```
       <?php $counter=0;
       ...query_posts...if you need it...
       if (have_posts()) :
       while (have_posts()) : the_post(); ?>
       <?php $counter++; ?>
       <div class="post <?php if( $counter%4 == 0 ) { echo ' post_four'; ?>">
       ...the usual html/php for post title, content, postmetadata etc. ...
       </div> <!--end of .post -->
   
       <?php endwhile; endif; ?>
       ```
   
 * (untested)
 *  Thread Starter [greg9885](https://wordpress.org/support/users/greg9885/)
 * (@greg9885)
 * [16 years, 2 months ago](https://wordpress.org/support/topic/difficult-conditional-loop-problems/page/2/#post-1445275)
 * Yes this is for the front page and the “next page” as well (also known as page
   2). I tried implementing the code you gave me, but I don’t think it worked. Where
   should I put it?
 *  Thread Starter [greg9885](https://wordpress.org/support/users/greg9885/)
 * (@greg9885)
 * [16 years, 2 months ago](https://wordpress.org/support/topic/difficult-conditional-loop-problems/page/2/#post-1445295)
 * Ok, I’ve been trying to implement this with the code that works above but I’m
   having no luck at all. Also, I don’t know if it will display correctly anyway,
   because I’d like to have every 4th post be styled differently. So, I’d like the
   4th, 8th, 12th, etc styled with no padding. You can see what I mean [here](http://test.gregorydougherty.com).
 *  Thread Starter [greg9885](https://wordpress.org/support/users/greg9885/)
 * (@greg9885)
 * [16 years, 2 months ago](https://wordpress.org/support/topic/difficult-conditional-loop-problems/page/2/#post-1445296)
 * Ohh man, I just organized the post titles and realized that my posts are getting
   messed up between pages as well.
 * Here’s the code I’m using: [http://wordpress.pastebin.com/e4NQJUxP](http://wordpress.pastebin.com/e4NQJUxP).
   [Here’s where the sites located](http://www.test.gregorydougherty.com/).
 * If anyone can help out with this, I’d owe you a beer or thirty.
 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [16 years, 2 months ago](https://wordpress.org/support/topic/difficult-conditional-loop-problems/page/2/#post-1445298)
 * best to start a new thread with this new challenge – maybe someone will be able
   to find a solution.

Viewing 5 replies - 16 through 20 (of 20 total)

[←](https://wordpress.org/support/topic/difficult-conditional-loop-problems/?output_format=md)
[1](https://wordpress.org/support/topic/difficult-conditional-loop-problems/?output_format=md)
2

The topic ‘Difficult Conditional Loop Problems’ is closed to new replies.

## Tags

 * [conditional](https://wordpress.org/support/topic-tag/conditional/)
 * [loop](https://wordpress.org/support/topic-tag/loop/)
 * [the-loop](https://wordpress.org/support/topic-tag/the-loop/)

 * 20 replies
 * 2 participants
 * Last reply from: [Michael](https://wordpress.org/support/users/alchymyth/)
 * Last activity: [16 years, 2 months ago](https://wordpress.org/support/topic/difficult-conditional-loop-problems/page/2/#post-1445298)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
