WordPress Custom Post Type Loop

May 22nd, 2012 by
With this custom loop you can output custom post types to a page, simple rename the [YOUR POST TYPE] to your current post type name and put it in your page template. This output the title of the post with a link to the post (don’t forget the php tags…;)
<?php $loop = new WP_Query( array( 'post_type' => '[YOUR POST TYPE]', 'posts_per_page' => 8, order => 'DESC' ) );
while ( $loop->have_posts() ) : $loop->the_post(); ?>

  <?php the_permalink(); ?>
  <?php the_title(); ?>
  <?php the_content(); ?>
  <?php
	  if ( has_post_thumbnail() ) {
		  the_post_thumbnail('large');
		  }
		  else {
			  // do something else
			  }
	?>
<?php endwhile; ?>

Post a Comment

You must be logged in to post a comment.

Cached at: 2024-04-26 02:41:23am