Custom Post Type Search with Repeater template is not working
-
Hi,
I am using the ajax-load-more plugin with a custom post type in the archive page.
Now I want to do a search of that same post-type’s data and list out the results in the same archive page, (compatible with repeater templates too).
I have written the code into my theme’s functions.php file but it doesn’t get any results when I search with a particular value.
Below is my code:
function meta_search_query($wp_query) { global $wpdb, $post, $wp_query; $query_args_meta = array( 'posts_per_page' => 5, 'post_type' => 'custom_posttyp', 'meta_query'=> array( 'relation' => 'OR', array( 'key' => 'firstname', 'compare' => 'LIKE', 'value' => $_REQUEST['sterm'], ), array( 'key' => 'location', 'compare' => 'LIKE', 'value' => $_REQUEST['sterm'], ), array( 'key' => 'service_name', 'compare' => 'LIKE', 'value' => $_REQUEST['sterm'], ), ), ); $wp_query->set('post_type', array('custom_posttyp')); wp_reset_query(); wp_reset_postdata(); return $wp_query; } add_filter( 'pre_get_posts', 'meta_search_query'); ## add_action( 'pre_get_posts', 'meta_search_query');
Can anyone let me know why this doesn’t return any results?
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Custom Post Type Search with Repeater template is not working’ is closed to new replies.