How to display Course Duration & Number of Units under course on home page

Home Forums Legacy Support Support queries Setup issues How to display Course Duration & Number of Units under course on home page

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #268185
    prateekgupta2009
    Participant
    Hello, I want to display Course Duration & Number of Units on home page under course box, so what field or code i need to call for displaying those values as its displayed on single course page.
    #268472
    Veronica
    Moderator
    hi, I want to display Course Duration share the screenshot like exactly you want to show it  Number of Units on home page share both the screenshot where you want to show it and the screenshot for presently where is the number of units are showing just for the reference
    #269837
    prateekgupta2009
    Participant
    This reply has been marked as private.
    #269989
    Veronica
    Moderator
    hi, need to check the code if there is any hook then this can be done via shortcode please ping me for the same
    #269992
    prateekgupta2009
    Participant
    There is no hook created by us... Its in the WPLMS Code... i need either the shortcode or hook through which it can be done... couldn't find any code or variable thats being used to show on Single Course Display page so that we can call on home page as well...  If you need ftp or wp-admin access then let me know...
    #270364
    Anshuman Sahu
    Keymaster
    to get course duration use : get_the_course_time('course_id='.$course_id)   to get number of unit use : https://gist.github.com/alexvibealex/a009da03ca953c92af25e3ee72f43360
    #270388
    Steve
    Member
    Hello @prateekgupta2009 There is no other way to show these details together. Thank you
    #270421
    prateekgupta2009
    Participant
    I was able to show number of units, but for course duration i want total duration of course in hours like length of all unit 3.5 hours, 4 hours etc... not the course duration access.
    #270423
    prateekgupta2009
    Participant
    I am able to show time using below mentioned function, but its showing time in second. How to show time in decimal format like 3.5 or 4.2 Hours etc.. I want to show only 1 decimal value   //function to show course time function wplms_show_unit_time($course_id){ $course_id = get_the_ID(); $course_curriculum = bp_course_get_curriculum($course_id); $units=bp_course_get_curriculum_units($course_id);   $duration = $total_duration = 0; foreach($units as $unit){ $duration = get_post_meta($unit,'vibe_duration',true); if(get_post_type($unit)=='unit'){ $unit_duration_parameter = apply_filters('vibe_unit_duration_parameter',60,$unit); }elseif(get_post_type($unit)=='quiz'){ $unit_duration_parameter = apply_filters('vibe_quiz_duration_parameter',60,$unit); }   $total_duration =  $total_duration + $duration*$unit_duration_parameter; }   return $total_duration; }
    #270869
    Anshuman Sahu
    Keymaster
    well to get in hours simply change the last line :

    return $total_duration/(60*60);

     
    #270887
    prateekgupta2009
    Participant
    Thanks ....
    #270991
    Anonymous
    Inactive
    Dear prateekgupta2009, thanks for confirming. closing this topic.
Viewing 12 posts - 1 through 12 (of 12 total)
  • The topic ‘How to display Course Duration & Number of Units under course on home page’ is closed to new replies.