get_pay_per_posts( array( 'ID', 'post_title' ), false, $searched_term ); $results = array(); if ( ! empty( $pay_per_posts ) ) { foreach ( $pay_per_posts as $ppp ) { $results[] = array( 'id' => $ppp->ID, 'text' => $ppp->post_title, ); } } /* * data should be return like this using result as the key * when getting data using search */ return array( 'results' => $results ); } }