Grow your CSS skills. Land your dream job.

WordPress Custom Loop

  • # June 23, 2013 at 12:58 am

    I’ve got the following loop working great except I’m a little help on how to add a leading div with class row before three items and a closing div after them until it reaches the end.

    < ?php
    $wp_query = null;
    $wp_query = new WP_Query();
    $wp_query->query(‘cat=4′);
    ?>
    < ?php $i = 1; $row = 0; while ( $wp_query->have_posts() ) : $wp_query->the_post(); ?>

    # June 23, 2013 at 6:31 am

    try this

    < ?php
    $wp_query = null;
    $wp_query = new WP_Query();
    $wp_query->query(‘cat=4′);
    ?>
    div class=”row”>
    < ?php $i = 1; $row = 0; while ( $wp_query->have_posts() ) : $wp_query->the_post(); ?>

    < ?php echo get_the_post_thumbnail($page->ID, ‘full’); ?>

    “>

    < ?php the_title(); ?>

    < ?php if($i == 3 ){ echo '

    ‘ } $i++; endwhile; // end of the loop. ?>

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

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".