Support » Plugin: WPAdverts - Classifieds Plugin » checkbox search (and)

  • virtualars


    Is it possible to change the checkbox area so that it exactly looks for the selected checkboxes?

    currently, with all the tests I have done, even if I select 3 checkboxes, the search result is also just 1 checkbox, instead I wish it must have all of them is 3

Viewing 1 replies (of 1 total)
  • Plugin Author Greg Winiarski


    it is possible, i am not sure how you are adding the search fields but if you are using the WordPress API then it is just a matter to set the 'operator' => 'AND' in the WP_Query

    The custom fields extension does not have this option yet, so you would need to leave the “Search By” field empty in the form editor and in your theme functions.php file add the code below

    add_filter( "adverts_list_query", function( $args ) {
      if( adverts_request( "search_category" ) ) {
        $args["meta_query"][] = array(
          "taxonomy" => "advert_category",
          "field" => "term_id",
          "terms" => adverts_request( "search_category" ),
          "include_children" => true,
          "operator" => "AND"
      return $args;

    In the code above i am assuming your category search field in [adverts_list] is named “search_category” and the field options are using terms_ids in the <option> tags.

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.