Sample payload query arguments:
'post_tax_filter' => array(
'category' => array(1, 2),
function asp_custom_rest_handler( $data ) {
$defaults = $args = array(
$params = $data->get_params();
foreach ( $defaults as $k => $v ) {
if ( isset($params[$k]) && $params[$k] !== null ) {
if ( isset($params['post_tax_filter']) ) {
$args['post_tax_filter'] = array();
foreach ( $params['post_tax_filter'] as $taxonomy => $terms ) {
if ( taxonomy_exists($taxonomy) && is_array($terms) && count($terms) ) {
$args['post_tax_filter'][] = array(
'include' => array_map('intval', $terms),
$asp_query = new ASP_Query($args, $args['id']);
return $asp_query->posts;
// POST to: http://example.com/wp-json/ajax-search-pro/v2/id/1/search
add_action( 'rest_api_init', function () {
register_rest_route('ajax-search-pro/v0', '/search', array(
'callback' => 'asp_custom_rest_handler',