In this tutorial, we look at how to modify the WordPress Loop to display only submitted posts. This can be done for any loop in the theme template. For example, you could modify the loop used in archive.php to display only submitted posts in archive views.

Using USP’s template tag, usp_is_submitted(), this is actually trivial to achieve. Let’s say we have a typical (simplified) loop:

<?php if (have_posts()) : while (have_posts()) : the_post(); ?>

<div <?php post_class(); ?> id="post-<?php the_ID(); ?>">
	<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
	<?php the_content(''); ?>
</div>

<?php endwhile; else : endif; ?>

To modify the loop to display only submitted posts, add usp_is_submitted(), like so:

<?php if (have_posts()) : while (have_posts()) : the_post(); ?>

	<?php if (usp_is_submitted()) : ?>

	<div <?php post_class(); ?> id="post-<?php the_ID(); ?>">
		<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
		<?php the_content(''); ?>
	</div>

	<?php else : 
		// not a usp post
		continue;
	endif; ?>

<?php endwhile; else : endif; ?>

That’s all there is to it. Of course, this is a highly simplified example, so you’ll inevitably want to customize the implementation to suit your design goals.

For more useful USP template tags, visit the USP Pro Template Tags reference »