• greg9885

    (@greg9885)


    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)
  • Michael

    (@alchymyth)

    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

    (@greg9885)

    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

    (@greg9885)

    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.

    Thread Starter greg9885

    (@greg9885)

    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. Here’s where the sites located.

    If anyone can help out with this, I’d owe you a beer or thirty.

    Michael

    (@alchymyth)

    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)

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