Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)
  • $wp_query->current_post

    is the index of the current post within the loop so it may be easier to do something like this. (I’ used post_class() for the div classes, it is in WP 2.7 + )

    //start the loop
    <?php if (have_posts()) : while (have - blah blah blah ?>
    ...
    <?php
    $myDivClasses = array('unit');
    // if it's the first(zeroth) post, size1of1 class else size1of2 class
    $myDivClasses []= ($wp_query->current_post == 0) ? 'size1of1' : 'size1of2';
    
    // add lastUnit class to odd divs (including first)
    if ($wp_query->current_post % 2 == 0)
    	$myDivClasses []= 'lastUnit';
    
    // if this is the last post found it's a lastUnit
    if ($wp_query->post_count == $wp_query->current_post + 1)
    	$myDivClasses []= 'lastUnit';
    ?>
    <!-- Now do your div with it's post classes -->
    <div <?php post_class($myDivClasses); ?>>
    ...
    </div>
    <?php endwhile; endif; ?>

    the []= operator adds a value to an array
    current_post is zero based so add 1 to it for comparison

    start at the top and get rid of this

    <style>
    
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <meta content="text/html; charset=iso-8859-2" http-equiv=Content-Type>

    and this at the end

    </STYLE>

    that stuff does not belong in a stylesheet, then do something about this rule

    td, p, div {color:#4f4f4f; font-family:Trebuchet MS; font-size:11px; line-height: 12px;}

    since you are telling all paragraphs to have a color of #4f4f4f you need to be more specific with the comment rule or this one will just override it. this will work (but it’s an ugly way to do it)

    .commentlist li p {color:#fff}

    You can use the firebug plugin for firefox to untangle css messes.

Viewing 2 replies - 1 through 2 (of 2 total)