digisavvy
6/18/2013 - 6:03 PM

Just a simple query put together using WP_Query. I used this on a site to list out course materials (custom post type) to the currently logg

Just a simple query put together using WP_Query. I used this on a site to list out course materials (custom post type) to the currently logged-in user. The user will only see courses that they have the capability to see.

This is used in Conjunction with Jigoshop and the Groups/Subscriptions plugin from Itthinx.

<?php

  $args = array(
	     	'post_type' => 'courses',
		'perm' => 'readable',
		'order' => 'DESC',
		'orderby' => 'title',
               	'posts_per_page' => -1	      
	);

	$course_posts = new WP_Query($args);

	   if($course_posts->have_posts()) : 
	      while($course_posts->have_posts()) : 
	         $course_posts->the_post();
	?>

	<ul class="display-posts-listing">
	         <li class="listing-item"><a href="<?php echo get_permalink( ); ?>" title="<?php the_title() ?>"><?php the_title() ?></a></li>
	</ul>
	      
	<?php
	      endwhile;
	   else: 
	?>

	      Oops, there are no posts.

	<?php
	   endif;

// Reset Post Data
wp_reset_postdata();

?>