Hi, do you mean that when you enter in ИНН value “Testing” and then in [adverts_list] search for “Testing” no results are found?
If so then i am afraid that it is not really possible to search like that out of box. The keyword field can only search in title and description.
What you can do is add the ИНН field to the [adverts_list] form https://wpadverts.com/documentation/custom-fields-search-form/
There also seems to be a way to modify the WP_Query object to search by both title/description and a custom field but it requires some porgramming https://wordpress.stackexchange.com/questions/78649/using-meta-query-meta-query-with-a-search-query-s
I have never tried the solution prosed there so i cannot tell if it works, but when i will find some free time i will test it (hopefully this week).
thank you for the answer!
i’ve added the ИНН field to the [adverts_list] form:
add_filter( 'adverts_form_load', 'search_by_INN' );
function search_by_INN( $form ) {
if( $form['name'] != 'search' ) {
return $form;
}
$form['field'][] = array(
"name" => "query",
"type" => "adverts_field_text",
"order" => 10,
"label" => "",
"placeholder" => __("ИНН ...", "adverts"),
"meta" => array(
"search_group" => "visible",
"search_type" => "half"
)
);
return $form;
}
but i don’t understand how i can modify the code below:
add_filter( 'adverts_list_query', 'search_by_INN_query' );
function search_by_INN_query( $args ) {
if( ! adverts_request( "advert_category" ) ) {
return $args;
}
$args["tax_query"] = array(
array(
'taxonomy' => 'advert_category',
'field' => 'term_id',
'terms' => adverts_request( "advert_category" ),
),
);
return $args;
}
besides it looks like the search form stopped working in general http://xn—-8sbafhjd1b1adcehode7af3p.xn--p1ai/?page_id=88
Hi, the INN you are storing in the meta fields, so your search_by_INN_query() function should look like this
function search_by_INN_query( $args ) {
if( adverts_request( "inn" ) ) {
$args["meta_query"][] = array(
'key' => 'adverts_price',
'value' => adverts_request( 'inn' ),
);
return $args;
}
Additionally, in the search_by_INN() function you will need to change line "name" => "query",
to "name" => "inn",
.
Once you do that try refreshing the page and do a search again.