This website uses cookies to personalize your experience. By using this website you agree to our cookie policy.

Exclude Taxonomy if count 0

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Exclude Taxonomy if count 0

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #18416
    ilanbilanb
    Participant

    Hello,

    I try to exclude from search the taxonomy “product_brand” if count = 0

    I’v put in function.php this function (14 is the id of brand search)

    [php]add_filter("asp_query_args", "asp_query_args_change", 1, 14);
    function asp_query_args_change($args, $search_id)
    {
    // Find "product_brand" where count = 0 and exclude from search
    //$brands = $wpdb->get_results("");

    //update phiz_term_taxonomy p set p.count = 0 where p.term_id not in (select term_taxonomy_id from phiz_term_relationships)

    // Filter it
    $args[‘post_tax_filter’] = array(
    array(
    ‘taxonomy’ => ‘product_brand’,
    ‘exclude’ => $brands
    )
    );
    return $args;
    }[/php]

    How can I get all id with count 0 of taxonomy “product_brand” ?
    This is the right function ?

    Thanks

    Ilan

    #18424
    Ernest MarcinkoErnest Marcinko
    Keymaster

    Hi Ilan,

    I assume you want to exlude taxonomy terms from results, where there are no items associated with them. That code unfortunately is not correct, but I have one that will work.

    Add this custom code to the functions.php in your theme/child theme directory (copy from line 3 only!). Before editing, please make sure to have a full site back-up just in case!

    #18425
    ilanbilanb
    Participant

    SIMPLE and PERFECT as always 🙂

    Thanks Ernest !

    #18426
    Ernest MarcinkoErnest Marcinko
    Keymaster

    You cannot access this content.

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘Exclude Taxonomy if count 0’ is closed to new replies.