Skip to content

Instantly share code, notes, and snippets.

@oneblackcrayon
Created September 25, 2014 20:34
Show Gist options
  • Save oneblackcrayon/3103e9e966b4cb538a2d to your computer and use it in GitHub Desktop.
Save oneblackcrayon/3103e9e966b4cb538a2d to your computer and use it in GitHub Desktop.
A custom WordPress loop from somewhere on the Internet.
<?php if (have_posts()) : ?>
<?php if (($wp_query->post_count) > 1) : ?>
<?php while (have_posts()) : the_post(); ?>
<!-- Do your post header stuff here for excerpts-->
<?php the_excerpt() ?>
<!-- Do your post footer stuff here for excerpts-->
<?php endwhile; ?>
<?php else : ?>
<?php while (have_posts()) : the_post(); ?>
<!-- Do your post header stuff here for single post-->
<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a>
<?php the_content() ?>
<a href="<?php the_permalink(); ?>">permalink</a>
This entry was posted on <?php the_time('l, F jS, Y') ?> at <?php the_time() ?> and is filed under <?php the_category(', ') ?>. More by <?php the_author_posts_link() ?>.
<!-- Do your post footer stuff here for single post-->
<?php if ( get_the_author_meta( 'description' ) ) : ?>
<?php echo get_avatar( get_the_author_meta( 'user_email' ) ); ?>
<h2><?php printf( get_the_author() ); ?></h2>
<?php the_author_meta( 'description' ); ?>
<?php endif; ?>
<?php endwhile; ?>
<?php endif; ?>
<?php else : ?>
<!-- Stuff to do if there are no posts-->
<?php _e( 'Not Found'); ?>
<?php endif; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment