Custom Features Course block

Home Forums Legacy Support Support queries Setup issues Custom Features Course block

Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #274204
    Needhi
    Participant
    Hi,   I am creating a custom course block with you code:   function custom_vibe_featured_thumbnail_style($thumbnail_html,$post,$style){ if($style == 'custom_block'){ //Custom block is the same name as added for the thumbnail in pagebuilder $thumbnail_html =''; $thumbnail_html .= ''; $thumbnail_html .= ''; $thumbnail_html .= ''.get_the_post_thumbnail($post->ID,'medium').''; $thumbnail_html .= 'Academic'; $thumbnail_html .= ''; $thumbnail_html .= ''; $thumbnail_html .= 'post_title.'">'.$post->post_title.''; $thumbnail_html .= ''; } return $thumbnail_html; }   However, i need to know, how can i call the permalink for category and link with specific post category, link in the above code, i have manally added the course category. Also, tell me how can give course code in this code,and where i need to enter course code in course, as i we have section, where certificate is generate based on course code.
    #274372
    Diana
    Participant
    You have the post id, using that you can fetch the category. Check this wordpress function: https://stackoverflow.com/questions/17303840/get-category-name-from-post-id
    #274824
    Needhi
    Participant
    you mean to say i need to create seperate function for this, as stack overflow post is not clear, can you please help what code exactly i need to add in customizer
    #274920
    Veronica
    Moderator
    hi, yes here it is here you go get_the_category( $post->ID ); will return the array of categories of that post you need to loop through the array
    $category_detail=get_the_category('4');//$post->ID
    foreach($category_detail as $cd){
    echo $cd->cat_name;
    }
    #275025
    Needhi
    Participant
    this code is not clear, lot of span, not able to see the exact function. kindly share the exact function
    #275026
    Needhi
    Participant
    also get_the_category function is inbuilt I m using it like this     $thumbnail_html .= ''.get_the_category($post->ID).''; but still no success
    #275181
    Veronica
    Moderator
    here you go get_the_category( $post->ID ); will return the array of categories of that post you need to loop through the array $category_detail=get_the_category('4');//$post->ID foreach($category_detail as $cd){ echo $cd->cat_name; } http://prntscr.com/tjk1fn
    #275280
    Needhi
    Participant
    This reply has been marked as private.
    #276035
    Veronica
    Moderator
    hi, sorry for the delay in response please let me know what you exactly want to fetch with this custom block if you just want to save permalink and fetch the post id then providing the code for the same
    #277518
    Needhi
    Participant
    Hi, first, i need to fetch category and then Author and also let me know how can i add custom course ID to this, so that same can also be fetched.
    #277863
    Anshuman Sahu
    Keymaster
    for course codes : https://wplms.io/support/knowledge-base/course-codes/   Here is how you can fetch the course categories : $cats = wp_get_post_terms( $course_id,'course-cat');                          if( !empty($cats)){                             $return .='';                             foreach($cats as $cat){                                 $return .= 'term_id ).'" class="postblock_cat">'.$cat->name.'';                             }                              $return .='';                         }     get_category_link.  is the function which provides link and wp_get_post_terms which provided course categories .
    #278179
    Needhi
    Participant
    Hi, but where i need to give this code, i have already shared my custome code with you, kindly provide the code ,where i need to enter that.
    #278452
    Anshuman Sahu
    Keymaster
Viewing 13 posts - 1 through 13 (of 13 total)
  • The topic ‘Custom Features Course block’ is closed to new replies.