Advertisement
mbis

BasePress support knowledgebase

Aug 17th, 2020
2,806
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.61 KB | None | 0 0
  1. function pm_kb_categories_query($query, $old_query, $uri_parts, $pm_query, $content_type) {
  2.     if(isset($query['knowledgebase_cat']) && !empty($pm_query['id']) && strpos($pm_query['id'], 'tax-') !== false) {
  3.         $query['post_type'] = 'knowledgebase';
  4.         unset($query['taxonomy']);
  5.         unset($query['term']);
  6.        
  7.         $term_id = intval(preg_replace("/[^0-9]/", "", $pm_query['id']));
  8.         $term = get_term($term_id);
  9.        
  10.         if(empty($term->parent)) {
  11.             $query['is_knowledgebase_product'] = 1;
  12.         }
  13.     }
  14.  
  15.     return $query;
  16. }
  17. add_filter('permalink_manager_filter_query', 'pm_kb_categories_query', 5, 5);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement