Forum Replies Created

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter vkranendonk

    (@vkranendonk)

    I got the solution by applying this https://www.dfactory.eu/get_terms-post-type/ with some modifications.

    Would still be nice if hide empty checks on current post type and on filters already active (but understand this no small fix).

    if ( ! is_admin() ) {
    
      function df_terms_clauses($clauses, $taxonomy, $args) {
    
          if(!($args['hide_empty'] && (empty($args['class']) || $args['class'] == "beautiful-taxonomy-filters-select"))) return $clauses;
    
          $query_post_type = get_query_var('post_type');
          $args['post_type'] = is_array($query_post_type) ? $query_post_type : array($query_post_type);
    
          if (!empty($args['post_type'])) {
            global $wpdb;
    
            $post_types = array();
    
            foreach ($args['post_type'] as $cpt) {
              $post_types[] = "'" . $cpt . "'";
            }
    
            if (!empty($post_types)) {
              $clauses['fields'] = 'DISTINCT ' . str_replace('tt.*', 'tt.term_taxonomy_id, tt.term_id, tt.taxonomy, tt.description, tt.parent', $clauses['fields']) . ', COUNT(t.term_id) AS count';
              $clauses['join'] .= ' INNER JOIN ' . $wpdb->term_relationships . ' AS r ON r.term_taxonomy_id = tt.term_taxonomy_id INNER JOIN ' . $wpdb->posts . ' AS p ON p.ID = r.object_id';
              $clauses['where'] .= ' AND p.post_type IN (' . implode(',', $post_types) . ')';
              $clauses['orderby'] = 'GROUP BY t.term_id ' . $clauses['orderby'];
            }
          }
          return $clauses;
    
      }
      add_filter('terms_clauses', 'df_terms_clauses', 10, 3);
    
    }

    The code works for me, with and without Select2, BTF 1.2.9 and WordPress 4.4.2.

    Perhaps it is:
    – Browser specific, my test was in Chrome.
    – Some other script is blocking this script.
    – Jquery is not available

    $('.beautiful-taxonomy-filters-select').on('change', function(){
        $('#beautiful-taxonomy-filters-form').submit();
    });
    Thread Starter vkranendonk

    (@vkranendonk)

    My apologies, problem is solved. ‘Link this post to its children’ needs to be checked to save the connection.

Viewing 3 replies - 1 through 3 (of 3 total)