Retrieving Learnpress Categories via Post_Object
-
I am having trouble figuring out how to show only certain courses on a page using their category. I understand the courses can be accessed based on their category by going to /course-category/<category>, but I need to be able to retrieve the courses dynamically on showing a certain course category to a certain user role.
This is the code I am currently using:
$args = array( 'posts_per_page' => 5, 'offset' => 0, 'category' => '', 'category_name' => '', 'orderby' => 'date', 'order' => 'DESC', 'include' => '', 'exclude' => '', 'meta_key' => '', 'meta_value' => '', 'post_type' => 'lp_course', 'post_mime_type' => '', 'post_parent' => '', 'author' => '', 'author_name' => '', 'post_status' => 'publish', 'suppress_filters' => true ); $posts_array = get_posts( $args );
This code however does not display the category of the course inside the array. I’ve tried entering the category manually by entering it into both the “category” and “category_name” arguments, but it doesn’t seem to have any effect on what is filtered. Not sure what I am doing wrong, and any help is greatly appreciated. Thanks!
- The topic ‘Retrieving Learnpress Categories via Post_Object’ is closed to new replies.