digisavvy
4/12/2015 - 7:31 PM

WP Query to display posts current user has capabilities to see

WP Query to display posts current user has capabilities to see

<?php

	$args = array(
		'post_type' => 'course',
		'perm' => 'readable',
		'order' => 'ASC',
		'orderby' => 'title',
		'posts_per_page' => -1,
		'READ_ACCESS' => 'read_access',
		'post__not_in' => array(  1271 )
	);

$course_posts = new WP_Query($args);

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

	<li><a href="<?php echo get_permalink( ); ?>" title="<?php the_title() ?>"><?php the_title() ?></a></li>

		<?php
		      endwhile;
		   else:
		?>

		    //  Oops, there are no posts.

		<?php
		   endif;

	// Reset Post Data
	wp_reset_postdata();

	?>