• rakesh1974

    (@rakesh1974)


    Hi

    We need to show related courses on the user dashboard or a separate link, only from those categories where he has purchased the course from…

    How can we do that?

    Thanks

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support brianvu-tp

    (@briantp)

    You need to edit a lot of code to do that. This is a function to get related course.

    
    

    if ( ! function_exists( ‘thim_get_related_courses’ ) ) {
    function thim_get_related_courses( $limit ) {
    if ( ! $limit ) {
    $limit = 3;
    }
    $course_id = get_the_ID();

    $tag_ids = array();
    $tags = get_the_terms( $course_id, ‘course_tag’ );

    if ( $tags ) {
    foreach ( $tags as $individual_tag ) {
    $tag_ids[] = $individual_tag->term_id;
    }
    }

    $args = array(
    ‘posts_per_page’ => $limit,
    ‘paged’ => 1,
    ‘ignore_sticky_posts’ => 1,
    ‘post__not_in’ => array( $course_id ),
    ‘post_type’ => ‘lp_course’
    );

    if ( $tag_ids ) {
    $args[‘tax_query’] = array(
    array(
    ‘taxonomy’ => ‘course_tag’,
    ‘field’ => ‘term_id’,
    ‘terms’ => $tag_ids
    )
    );
    }
    $related = array();
    if ( $posts = new WP_Query( $args ) ) {
    global $post;
    while ( $posts->have_posts() ) {
    $posts->the_post();
    $related[] = $post;
    }
    }
    wp_reset_query();

    return $related;
    }
    }`
    `

    Thread Starter rakesh1974

    (@rakesh1974)

    @briantp

    Thanks a lot…

    Also pl let me know which page has this code to be used, is it functions.php?

    Thread Starter rakesh1974

    (@rakesh1974)

    @briantp

    there is no response on this pl give us more details
    Kindly let me know which page I should be adding this code

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Show related courses’ is closed to new replies.