Last active
December 18, 2015 15:58
-
-
Save digisavvy/5807775 to your computer and use it in GitHub Desktop.
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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(); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment