Home › Forums › Legacy Support › Support queries › Other issues › Hide All Courses in particular Course Category
- This topic has 45 replies, 5 voices, and was last updated 3 years, 11 months ago by Anshuman Sahu.
-
AuthorPosts
-
December 18, 2019 at 12:39 pm #237208ZatakkSpectatorHi I want to hide courses which belong to a particular course category. I badly need it. Instead of hiding one by one each course I want to be able to select one category and hide it. Most Urgent !! Regards Shailendra RDecember 19, 2019 at 12:38 pm #237311loganMemberHello, add this code in your customizer.php function logan_filter_pre_get_posts( $query ) { if ( ! is_singular() && $query->is_main_query() ) { $query->set( 'post__not_in', array( 123, 11, 12, 13 ) ); } } add_action( 'pre_get_posts', 'logan_filter_pre_get_posts' ); add you post/page/course id in array.December 25, 2019 at 5:39 am #237685ZatakkSpectatorThats not working . Anyway this can be easily done by Vibe Options => Hide Course from Directory. My query is for hiding all courses which belong to a particular course category !! Pls helpDecember 26, 2019 at 10:37 am #237732VeronicaModeratorhey have a look on this tip: https://www.wpbeginner.com/wp-tutorials/how-to-exclude-a-category-from-your-wordpress-homepage/ try these. for the code, use course category id with minus (-) sign. this should workDecember 27, 2019 at 8:33 am #237801ZatakkSpectatorDecember 27, 2019 at 9:51 am #237805ZatakkSpectatorSeems this was already asked earlier a couple of years before https://wplms.io/support/forums/topic/hide-content-from-course-category/December 28, 2019 at 5:34 am #237880Anshuman SahuKeymasterthis is possible.we will share the code to do it. Please provide some time . Please ping back for reminderDecember 30, 2019 at 7:23 am #237957ZatakkSpectatorHi Alex Just a friendly reminder :)December 30, 2019 at 1:11 pm #237983loganMember
Hello,
add this code in your customizer.php
add_filter('wplms_carousel_course_filters','wplms_exlude_courses_directroy_cc',99); add_filter('wplms_grid_course_filters','wplms_exlude_courses_directroy_cc',99); add_filter('vibe_editor_filterable_type','wplms_exlude_courses_directroy_cc',99); add_filter('bp_course_wplms_filters','wplms_exlude_courses_directroy_cc',99); add_filter('vibe_related_courses','wplms_exlude_courses_directroy_cc',99); function wplms_exlude_courses_directroy_cc($args){ if($args['post_type'] == 'course'){ if(isset($args['meta_query']) && is_array($args['meta_query']) && is_user_logged_in()){ $user_id=get_current_user_id(); foreach($args['meta_query'] as $query){ if(isset($query) && is_array($query)){ if($query['key'] == $user_id){ return $args; } } } } $excluded_courses=vibe_get_option('hide_courses'); if(!empty($excluded_courses) && is_array($excluded_courses) && !(isset($args['author']) || isset($args['author_name']))){ if(!empty($args['post__not_in'])){ $args['post__not_in'] = array_merge($args['post__not_in'], $excluded_courses); }else{ $args['post__not_in'] = $excluded_courses; } } $args = array( 'post_type' => 'course', 'tax_query' => array( array( 'taxonomy' => 'course-cat', 'field' => 'slug', //can be set to ID 'terms' => 'technology' //if field is ID you can reference by cat/term number ) ) ); $query = new WP_Query( $args ); if ($query->have_posts()) : while ($query->have_posts()) : $query->the_post(); if(!empty($args['post__not_in'])){ $args['post__not_in'][] = get_the_ID(); }else{ $args['post__not_in'] = array(get_the_ID()); } endwhile; endif; wp_reset_postdata(); } return $args; }December 31, 2019 at 12:41 pm #238080ZatakkSpectatorHi- I copied the code as it is.
All courses are hidden
Where should I give the input ?
I have only added the "slug" however, Adding any or many slugs is not helping !!
Pls help
December 31, 2019 at 1:19 pm #238083ZatakkSpectatorThis is the status as shown in the pic http://prnt.sc/qhwgkoJanuary 2, 2020 at 10:31 am #238168DianaParticipantThis reply has been marked as private.January 4, 2020 at 5:56 am #238314ZatakkSpectatorHi Any LuckJanuary 6, 2020 at 5:45 am #238422DianaParticipantThis reply has been marked as private.January 8, 2020 at 2:27 pm #238716ZatakkSpectatorHi There -
AuthorPosts
- The topic ‘Hide All Courses in particular Course Category’ is closed to new replies.