Home › Forums › Legacy Support › Support queries › Setup issues › Custom Features Course block
- This topic has 12 replies, 4 voices, and was last updated 3 years, 9 months ago by Anshuman Sahu.
Viewing 13 posts - 1 through 13 (of 13 total)
-
AuthorPosts
-
July 12, 2020 at 5:08 pm #274204NeedhiParticipantHi, 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.July 13, 2020 at 1:25 pm #274372DianaParticipantYou 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-idJuly 15, 2020 at 5:53 pm #274824NeedhiParticipantyou 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 customizerJuly 16, 2020 at 8:05 am #274920VeronicaModeratorhi, 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; }
July 16, 2020 at 5:27 pm #275025NeedhiParticipantthis code is not clear, lot of span, not able to see the exact function. kindly share the exact functionJuly 16, 2020 at 5:51 pm #275026NeedhiParticipantalso get_the_category function is inbuilt I m using it like this $thumbnail_html .= ''.get_the_category($post->ID).''; but still no successJuly 17, 2020 at 11:35 am #275181VeronicaModeratorhere 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/tjk1fnJuly 17, 2020 at 4:34 pm #275280NeedhiParticipantThis reply has been marked as private.July 21, 2020 at 1:44 am #276035VeronicaModeratorhi, 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 sameJuly 25, 2020 at 12:11 pm #277518NeedhiParticipantHi, 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.July 27, 2020 at 12:18 pm #277863Anshuman SahuKeymasterfor 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 .July 28, 2020 at 12:23 pm #278179NeedhiParticipantHi, 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.July 29, 2020 at 2:24 pm #278452Anshuman SahuKeymasterok here is the code :https://gist.github.com/alexvibealex/3f91d5016319e069aac3acaa99aad363 -
AuthorPosts
Viewing 13 posts - 1 through 13 (of 13 total)
- The topic ‘Custom Features Course block’ is closed to new replies.