I am trying to get data through WP_Query,
I've created a Ajax Search, but it's showing wrong pages (posts),
also when I directly visit link with s parameter, it shows the correct pages (posts).
example.com/category/success-stories?s=data
admin-ajax.php request payload:
action: search_checkbox_call
category[]: 81
search: data
Data I can see in Network > Response tab by print_r($args):
Array
(
[post_type] => page
[category__in] => Array
(
[0] => 81
)
[post_status] => publish
[s] => data
[orderby] => DESC
[paged] => 1
)
AJax Response Code:
$cat_ids = $_POST['category'];
$ser = $_POST['services'];
$tech = $_POST['technology'];
$ind = $_POST['industry'];
if (($_POST['search']) !== '') {
$s = $_POST['search'];
} else {
$s = '';
}
global $wpdb;
$paged = $_POST['page'] + 1;
$args = array(
'post_type' => 'page',
'category__in' => $cat_ids,
'post_status' => 'publish',
's' => $s,
'orderby' => 'DESC',
'paged' => $paged
);
$new = new WP_Query($args);
Can someone tell me what's wrong in it?