Cleaning up my loops
-
Hey
I’m new to developing wordpress sites. Most of my prior experiences are using html & css.
I’m curious if there is a easier/cleaner way to achieve this. Basically I have two custom post types and I’m querying both of them. Im wondering if there is away to achieve this that might look a little cleaner?
<div class="recent-news-home"> <h3>RECENT NEWS</h3> <?php $newshomeloop = array('posts_per_page' => 2, 'post_type' => 'press-release'); query_posts($newshomeloop); ?> <?php if ( have_posts() ) : ?> <ul> <?php while (have_posts()) : the_post(); ?> <li> <h4><?php the_title(); ?><small> <?php the_time('F j, Y'); ?> </small></h4> <p><?php echo excerpt(20); ?></p> <a href="<?php the_permalink();?>">Detail ?</a> </li> <?php endwhile; ?> </ul> <?php endif; wp_reset_query();?> </div> <div class="events"> <?php $events = array('posts_per_page' => 1, 'post_type' => 'events'); query_posts($events); ?> <?php if ( have_posts() ) : ?> <h2>Upcoming Events</h2> <?php while (have_posts()) : the_post(); ?> <div class="event-date"> <div class="day"> 30 </div> <span>Sep</span>2013 </div> <div class="event-info"> <h3><?php the_title(); ?></h3> <p><?php echo excerpt(20); ?></p> <a href="<?php the_permalink(); ?>">Details ?</a> </div> </div> <?php endwhile; ?> <?php endif; wp_reset_query();?> </div>
- The topic ‘Cleaning up my loops’ is closed to new replies.