Skip to content

Instantly share code, notes, and snippets.

@digisavvy
Last active August 29, 2015 14:19
Show Gist options
  • Save digisavvy/784395c5b8ddfff8eb13 to your computer and use it in GitHub Desktop.
Save digisavvy/784395c5b8ddfff8eb13 to your computer and use it in GitHub Desktop.
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();
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment