Support » Plugin: Co-Authors Plus » No courses (custom post) for co-autors

  • Hi,

    i use this plugin to show instructors’ name for our courses (each course has almost 2 instructors).

    But if he is an author, his course(s) are showed (as in this page he is a co-author, course(s) are not showed (as in this page

    This is code generates courses carousel in the bottom of the page:

    <?php /* Taught Courses */
    		$args = array(
    			'post_type' => 'course' ,
    			'author' => get_queried_object_id(), // this will be the author ID on the author page
    			'showposts' => 10
    		$custom_posts = new WP_Query( $args );
    		if ( $custom_posts->have_posts() ){ ?>
    		<div class="clearfix author-courses">
    			echo '<h4 class="course-title">'.esc_html__('Taught Courses','michigan').'</h4>';
    			echo '<div class="author-carousel">';
    			while ( $custom_posts->have_posts() ) : $custom_posts->the_post();
    				$post_id = get_the_ID();
    				$students = $wpdb->get_results($wpdb->prepare('SELECT user_id, meta_value, post_id FROM '.$wpdb->prefix . 'lifterlms_user_postmeta WHERE meta_key = "_status" AND meta_value = "Enrolled" AND post_id = %d AND EXISTS(SELECT 1 FROM ' . $wpdb->prefix . 'users WHERE ID = user_id) group by user_id',$post_id));
    				$course_students = rwmb_meta( 'michigan_course_students_meta' ) ? rwmb_meta( 'michigan_course_students_meta' ):count($students);
    				$image_m = get_the_image( array( 'meta_key' => array( 'thumbnail', 'thumbnail' ), 'size' => 'michigan_webnus_blog2_img','echo'=>false, ) );
    				$no_img_m = get_template_directory_uri().'/images/course_no_image.png';
    				$course_duration = get_post_meta( $post_id, '_llms_length', true );
    				echo '<article class="modern-grid llms-course-list"><div class="llms-course-link"><div class="modern-feature">';?>
    				<?php echo ($image_m)? $image_m :'<img src="' . $no_img_m . '" alt="Placeholder" class="w-no-img" />';
    				echo ($course_duration)?'<span class="modern-duration">'.$course_duration.'<i class="fa-clock-o"></i></span>':'';
    				echo '</div>'; //close modern feature
    				echo '<div class="modern-content">';
    				echo '<h3 class="llms-title"><a href="'.get_the_permalink().'">'.get_the_title().'</a></h3>';
    				if(function_exists('the_ratings')) {
    					echo expand_ratings_template('<div class="modern-rating"><span class="rating">%RATINGS_IMAGES%</span> <strong>(%RATINGS_USERS% '.esc_html__('Votes','michigan').')</strong></div>', get_the_ID());
    				echo '<div class="llms-price-wrapper"><h4 class="llms-price"><span>';
    				echo '</div>'; //close modern content
    				echo '<div class="clearfix modern-meta">';
    				echo '<div class="col-md-8 col-sm-8 col-xs-8">';
    				echo '<div class="modern-instructor">'.get_avatar( get_the_author_meta( 'user_email',$user_id ), 20 ) . get_the_author().'</div>';
    				echo '</div>';
    				echo '<div class="col-md-4 col-sm-4 col-xs-4">';
    				echo ($course_students)?'<span class="modern-students" title="'.esc_attr('Enrolled Students','michigan').'"><i class="sl-people"></i>'.$course_students.'</span>':'<span class="modern-viewers" title="'.esc_attr('Viewers','michigan').'"><i class="fa-eye"></i>'.michigan_webnus_getViews(get_the_ID()).'</span>';
    				echo '</div>';
    				echo'</div>'; //close modern meta
    				echo '</div></article>';
    		echo '</div>';
    		echo '</div>'; //close author courses
    			// nothing found

    Anyone could suggest a fix please?


    The page I need help with: [log in to see the link]

  • You must be logged in to reply to this topic.