How can I search through cpt attachments and content using ajax?

[ad_1]

Hello!

I have created a live ajax search that goes through a custom post type called “Resources.” Currently I can search and filter the results using a drop down to select the category, and a searchbar that uses the input value to run a search query. These two can be used in tandem to refine the results.

However, I noticed that the search only looks through the title of the post type. Overall my query is:

​

$cat = $_POST[‘cat’];
$search = sanitize_text_field($_POST[‘s’]);
$resourceQuery = new WP_Query([
‘post_type’ => ‘report’,
‘posts_per_page’ => 10,
‘status’ => ‘publish’,
‘s’ => $search,
‘paged’ => $_POST[‘paged’],
‘tax_query’ => [
[
‘taxonomy’ => ‘report-categories’,
‘terms’ => $cat
] ],
‘order’ => ‘DESC’,
‘orderby’ => ‘date’
]);

​

I have tried searching for results but I cannot find anything that can help. Does anyone know a good resource to help me figure out how to include content and attachments to the search?

Thanks!

[ad_2]

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer