• Resolved redearthdesign

    (@redearthdesign)


    Hello and thank you for sharing this great plugin!

    The category__and support is an excellent addition. In order to use it, I’ve set up this filter and function:

    add_filter('relevanssi_modify_wp_query', 'category_filter');
    
    function category_filter($wp_query) {
        $cat = $wp_query->query_vars['cat'];
        if(intval($cat) > 0 && $_REQUEST['and']){
            $secondcat = get_category_by_slug(strip_tags($_REQUEST['and']));
    
            $wp_query->query_vars['category__in'] = array($cat);
            $wp_query->query_vars['category__and'] = array($cat,$secondcat->cat_ID);
    
            return $wp_query;
        }
    }

    However, if there’s no category id (for All categories), it seems to be checking for ‘cat’ that before it gets to the if statement and shows this warning:

    Warning: Division by zero in … /wp-content/plugins/relevanssi/lib/search.php on line 912

    I’ve wrapped the entire filter and function in:

    if(intval($_REQUEST['cat']) > 0 && $_REQUEST['and']){ }

    but wanted to post this in case I’m overlooking a better way to approach this.

    Thanks!

    http://wordpress.org/extend/plugins/relevanssi/

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘using category__and with relevanssi_modify_wp_query’ is closed to new replies.