loop code cleanup

This commit is contained in:
Ben Word
2012-01-15 13:27:30 -07:00
parent b620f7b6c8
commit 3673baa402
4 changed files with 18 additions and 51 deletions

View File

@@ -4,7 +4,7 @@
<?php roots_post_inside_before(); ?> <?php roots_post_inside_before(); ?>
<h1><?php the_title(); ?></h1> <h1><?php the_title(); ?></h1>
<?php the_content(); ?> <?php the_content(); ?>
<?php wp_link_pages(array('before' => '<nav id="page-nav"><p>' . __('Pages:', 'roots'), 'after' => '</p></nav>' )); ?> <?php wp_link_pages(array('before' => '<nav id="page-nav"><p>' . __('Pages:', 'roots'), 'after' => '</p></nav>')); ?>
<?php roots_post_inside_after(); ?> <?php roots_post_inside_after(); ?>
<?php roots_post_after(); ?> <?php roots_post_after(); ?>
<?php endwhile; // End the loop ?> <?php endwhile; /* End loop */ ?>

View File

@@ -1,33 +0,0 @@
<?php /* If there are no posts to display, such as an empty archive page */ ?>
<?php if (!have_posts()) : ?>
<p><?php _e('Sorry, no results were found.', 'roots'); ?></p>
<?php get_search_form(); ?>
<?php endif; ?>
<?php /* Start loop */ ?>
<?php while (have_posts()) : the_post(); ?>
<?php roots_post_before(); ?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<?php roots_post_inside_before(); ?>
<header>
<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<?php roots_entry_meta(); ?>
</header>
<div class="entry-content">
<?php the_excerpt(); ?>
</div>
<footer>
<?php $tag = get_the_tags(); if (!$tag) { } else { ?><p><?php the_tags(); ?></p><?php } ?>
</footer>
<?php roots_post_inside_after(); ?>
</article>
<?php roots_post_after(); ?>
<?php endwhile; // End the loop ?>
<?php /* Display navigation to next/previous pages when applicable */ ?>
<?php if ($wp_query->max_num_pages > 1) : ?>
<nav id="post-nav">
<div class="post-previous"><?php next_posts_link( __( '&larr; Older posts', 'roots' ) ); ?></div>
<div class="post-next"><?php previous_posts_link( __( 'Newer posts &rarr;', 'roots' ) ); ?></div>
</nav>
<?php endif; ?>

View File

@@ -11,11 +11,11 @@
<?php the_content(); ?> <?php the_content(); ?>
</div> </div>
<footer> <footer>
<?php wp_link_pages(array('before' => '<nav id="page-nav"><p>' . __('Pages:', 'roots'), 'after' => '</p></nav>' )); ?> <?php wp_link_pages(array('before' => '<nav id="page-nav"><p>' . __('Pages:', 'roots'), 'after' => '</p></nav>')); ?>
<p><?php the_tags(); ?></p> <?php $tags = get_the_tags(); if ($tags) { ?><p><?php the_tags(); ?></p><?php } ?>
</footer> </footer>
<?php comments_template(); ?> <?php comments_template(); ?>
<?php roots_post_inside_after(); ?> <?php roots_post_inside_after(); ?>
</article> </article>
<?php roots_post_after(); ?> <?php roots_post_after(); ?>
<?php endwhile; // End the loop ?> <?php endwhile; /* End loop */ ?>

View File

@@ -1,8 +1,8 @@
<?php /* If there are no posts to display, such as an empty archive page */ ?> <?php /* If there are no posts to display, such as an empty archive page */ ?>
<?php if (!have_posts()) : ?> <?php if (!have_posts()) { ?>
<p><?php _e('Sorry, no results were found.', 'roots'); ?></p> <p><?php _e('Sorry, no results were found.', 'roots'); ?></p>
<?php get_search_form(); ?> <?php get_search_form(); ?>
<?php endif; ?> <?php } ?>
<?php /* Start loop */ ?> <?php /* Start loop */ ?>
<?php while (have_posts()) : the_post(); ?> <?php while (have_posts()) : the_post(); ?>
@@ -14,24 +14,24 @@
<?php roots_entry_meta(); ?> <?php roots_entry_meta(); ?>
</header> </header>
<div class="entry-content"> <div class="entry-content">
<?php if (is_archive() || is_search()) : // Only display excerpts for archives and search ?> <?php if (is_archive() || is_search()) { ?>
<?php the_excerpt(); ?> <?php the_excerpt(); ?>
<?php else : ?> <?php } else { ?>
<?php the_content(); ?> <?php the_content(); ?>
<?php endif; ?> <?php } ?>
</div> </div>
<footer> <footer>
<?php $tag = get_the_tags(); if (!$tag) { } else { ?><p><?php the_tags(); ?></p><?php } ?> <?php $tags = get_the_tags(); if ($tags) { ?><p><?php the_tags(); ?></p><?php } ?>
</footer> </footer>
<?php roots_post_inside_after(); ?> <?php roots_post_inside_after(); ?>
</article> </article>
<?php roots_post_after(); ?> <?php roots_post_after(); ?>
<?php endwhile; // End the loop ?> <?php endwhile; /* End loop */ ?>
<?php /* Display navigation to next/previous pages when applicable */ ?> <?php /* Display navigation to next/previous pages when applicable */ ?>
<?php if ($wp_query->max_num_pages > 1) : ?> <?php if ($wp_query->max_num_pages > 1) { ?>
<nav id="post-nav"> <nav id="post-nav">
<div class="post-previous"><?php next_posts_link( __( '&larr; Older posts', 'roots' ) ); ?></div> <div class="post-previous"><?php next_posts_link(__('&larr; Older posts', 'roots')); ?></div>
<div class="post-next"><?php previous_posts_link( __( 'Newer posts &rarr;', 'roots' ) ); ?></div> <div class="post-next"><?php previous_posts_link(__('Newer posts &rarr;', 'roots')); ?></div>
</nav> </nav>
<?php endif; ?> <?php } ?>