Display Wishlist Items from Shortcode
-
Hello, I am currently trying to display a user’s wishlist courses via a shortcode. I have code below that I have been modifying, however, I believe the error in pulling the wishlist courses back is coming from the ‘tutor-utils()->get_wishlist($user_id)’ line below. Would you have any recommendations as to how to approach this? Or if the wishlist info for a user is stored off-site from Worpress, how would I query to that? Thank you!
/** * Enrolled Course Shortcode */ function tutor_enrolled_course_register_shortcodes() { add_shortcode( 'enrolled-course', 'shortcode_tutor_enrolled_course' ); } add_action( 'init', 'tutor_enrolled_course_register_shortcodes' ); /** * Shortcode Callback */ function shortcode_tutor_enrolled_course( $atts ) { ?> <h3><?php _e('Enrolled Courses', 'tutor'); ?></h3> <div class="ians-course-wrapper"> <?php $user_id = get_current_user_id(); $my_courses = tutor_utils()->get_wishlist($user_id); if ($my_courses && $my_courses->have_posts()): while ($my_courses->have_posts()): $my_courses->the_post(); $post = $my_courses->post; ?> <a href="<?php the_permalink();?>"><?php the_post_thumbnail('thumbnail'); ?><?php the_title(); ?></a> <?php endwhile; wp_reset_postdata(); else: echo "<div class='tutor-mycourse-wrap'><div class='tutor-mycourse-content'>".__('You haven\'t enrolled in any courses.', 'tutor')."</div></div>"; endif; ?> </div> <?php }
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Display Wishlist Items from Shortcode’ is closed to new replies.