Support » Themes and Templates » 2 full posts, 18 excerpts

  • Resolved Anna

    (@ohthenoes)


    Which is working great. Except I was wondering how I might be able to insert a
    <ul> and </ul>
    for the 18 excerpts without having it repeat for each one?

    Much thanks in advance for help!

    Code is here:

    <div id="maincontenttop"></div>
    <div id="maincontent">
    <?php query_posts ('cat=1&posts_per_page=20'); if (have_posts()) : $count = 0; while (have_posts()) : the_post(); $count++; ?>
    <?php if ($count <= 2) : ?>
    <div class="postcontainer">
    <h2><?php the_time('m.d.y.') ?> <?php the_title(); ?></h2>
    <?php the_content(); ?>
    </div>
    <?php else : ?>
    <li><?php the_time('m.d.y.') ?> <a href="<?php the_permalink() ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></li>
    
    <?php endif; ?>
    <?php endwhile; ?>
    <?php else : ?>
    <?php endif; ?>
    </div>
    <div id="maincontentbot"></div>
Viewing 2 replies - 1 through 2 (of 2 total)
  • if count is 3 then insert the ul tag;
    after the loop, if count is 3 or more, close the ul tag:

    <?php if ($count <= 2) : ?>
    <div class="postcontainer">
    <h2><?php the_time('m.d.y.') ?> <?php the_title(); ?></h2>
    <?php the_content(); ?>
    </div>
    <?php else : ?>
    <?php if( $count == 3 ) echo '<ul>'; ?>
    <li><?php the_time('m.d.y.') ?> <a href="<?php the_permalink() ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></li>
    
    <?php endif; ?>
    <?php endwhile; ?>
    <?php if( $count >= 3 ) echo '</ul>'; ?>

    -untested-

    Worked perfectly. Thank you!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘2 full posts, 18 excerpts’ is closed to new replies.