Hide All Courses in particular Course Category

Home Forums Legacy Support Support queries Other issues Hide All Courses in particular Course Category

Viewing 15 posts - 31 through 45 (of 46 total)
  • Author
    Posts
  • #240940
    Zatakk
    Spectator
    @Diana Hi !! Any updates please  
    #241191
    Anshuman Sahu
    Keymaster
    Well you gotta add these widgets in order to make that work : Buddypress course filter widget and Buddypress course category Navigation widgets .
    #241215
    Zatakk
    Spectator
    Hi Where do I add them ....
    #241352
    Diana
    Participant
    This reply has been marked as private.
    #256237
    Zatakk
    Spectator
    Hi This is still unresolved. The code didnt work. See. if its working at your end, then let me have a video screen share of the same because for some reason it doesnt work at my end.
    #256546
    Anshuman Sahu
    Keymaster
    Try this code  :       add_filter('wplms_carousel_course_filters','wplms_exlude_courses_directroy',99999); add_filter('wplms_grid_course_filters','wplms_exlude_courses_directroy',99999); add_filter('vibe_editor_filterable_type','wplms_exlude_courses_directroy',99999); add_filter('bp_course_wplms_filters','wplms_exlude_courses_directroy',99999); add_filter('vibe_related_courses','wplms_exlude_courses_directroy',99999);   function wplms_exlude_courses_directroy($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 =array();            $args = array(         'post_type' => 'course',         'tax_query' => array(         array(         'taxonomy' => 'course-cat',         'field' => 'slug', //can be set to ID       'taxonomy' => 'course-cat',         'field' => 'slug', //can be set to ID         'terms' => 'technology' //if field is ID you can reference by cat/term number         )         )         );                   $category_posts = new WP_Query($args);                   if($category_posts->have_posts()) :         while($category_posts->have_posts()) :         $category_posts->the_post();         $excluded_courses[] = get_the_ID();         endwhile;         endif;         wp_reset_postdata();           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;         }     }    }   return $args;     }    
    #256679
    Zatakk
    Spectator
    Sorry But I dont think thats working at all.
    1. I have taken one category "p-career" and added to the widgets. 2. Made the changes to the code in customizer and added the category slug "p-career"

    2. The Course Filter Pages are not responding.

    3. No courses are seen in the 'All Courses' Page.

    4. The widgets are added to the Course Sidebar and Main Sidebar. But they are not showing even after changing the page template to Left or right side bar. Course Category Page doesnt shown any  courses at all except "My Courses".

    If its working at your end, could you pls share the exact way to replicate it at my end ??/    

    #256944
    Anshuman Sahu
    Keymaster
    try this code :     add_filter('wplms_carousel_course_filters','wplms_exlude_courses_directroy1',99999);   add_filter('wplms_grid_course_filters','wplms_exlude_courses_directroy1',99999);   add_filter('vibe_editor_filterable_type','wplms_exlude_courses_directroy1',99999);   add_filter('bp_course_wplms_filters','wplms_exlude_courses_directroy1',99999);   add_filter('vibe_related_courses','wplms_exlude_courses_directroy1',99999);       function wplms_exlude_courses_directroy1($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;                 }             }           }       }          wp_reset_postdata();       $excluded_courses =array();                  $args1 = 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             )             )             );                           $category_posts = new WP_Query($args1);                           if($category_posts->have_posts()) :             while($category_posts->have_posts()) :             $category_posts->the_post();             $excluded_courses[] = get_the_ID();             endwhile;             endif;             wp_reset_postdata();                   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;           }       }      }     return $args;       }
    #257295
    Zatakk
    Spectator
    Sorry but Not working. Could you check once if it works and then share with me. Also can you tell what exactly you are expecting this code to do. We have course category pages and course filter pages. Course filter page says error encountered. The course filter pages are not loading. https://www.constructionworld.online/constrution-courses/ https://www.constructionworld.online/ce-academic-courses/ Only All Courses Page I think it works. But the draft courses are also visible....The All Courses Number doesnt seem to change. Also how to give slugs for multiple course categories ??  
    #257496
    Anshuman Sahu
    Keymaster
    Please share ftps to check the code. It works absolutely fine at our end , checked on all courses page . Yes the count will have problem. that code is not shared . We are actually very busy with the 4.0  but still trying to help you out . share the ftps we will check it .
    #257575
    Zatakk
    Spectator
    This reply has been marked as private.
    #257999
    Anshuman Sahu
    Keymaster
    Corrected at your end please check  now .
    #258046
    Zatakk
    Spectator
    This reply has been marked as private.
    #258330
    Anshuman Sahu
    Keymaster
    Well i have to do that all over again . I do not exactly remember the code now . If you have backup please make use of it.
    #258350
    Zatakk
    Spectator
    My backup is having the older code. And that was a really bad expereince. You had solved that for the parent category pretty well including the count of the courses. Request you to please see if there is any backup stored at your end. I was almost sure you would have it stored it somewhere safe. But if time doesnt permit, pls come back later....only thing is if you could just give some time, the code may come back faster. It was really good code, simple small and compact.    
Viewing 15 posts - 31 through 45 (of 46 total)
  • The topic ‘Hide All Courses in particular Course Category’ is closed to new replies.