Filter WP user acf field by ajax

The problem is your action names don’t match In your frontend code: ?action=find_coach’; But in your backend code: add_action(‘wp_ajax_search_coach’, ‘searchLifeCoach’); add_action(‘wp_ajax_nopriv_search_coach’, ‘searchLifeCoach’); search_coach != find_coach, they have to match. Note that if this code used the REST API, it would have given a 404 and stated the problem in human readable language, e.g. { “code”:”rest_no_route”, … Read more

How can I customize the search results in Bones theme?

Filter ‘the_excerpt’ on the search page only: add_filter( ‘the_excerpt’, ‘wpse_99415_search_excerpt’ ); function wpse_99415_search_excerpt( $excerpt ) { if ( ! is_search() ) return $excerpt; global $post; // create a custom excerpt return $custom_excerpt; }

Separating search results collectively by type

There’s two options. The first and probably the easiest option is to run the query twice on the page in each place you want to use it. // Author Block while(have_posts()) : the_post(); if ( ‘book-author’ == get_post_type() ) { ?> <h2>AUTHOR</h2> <?php the_title(); } endwhile; rewind_posts(); // Book Block while(have_posts()) : the_post(); if ( … Read more

Get the selected term in a dropdown search

To show dropdown with currently selected option, first you need to fetch current value. You can get that value from $_REQUEST variable. If you have grade variable then your current value is $_REQUEST[‘grade’]. Eg. if ($_REQUEST[‘grade’] == $term->slug) Recommended: Do not use REQUEST variable directly without sanitization. Use function like esc_attr. If you are sure … Read more

WordPress Single Conditional for Search Page

You could hook into the the_permalink filter and check for is_search() to conditionally modify the URLs of your search results to include some additional parameters that your single.php then checks for. Something like this (may require tinkering): add_filter( ‘the_permalink’, ‘wpse155331_the_permalink’ ); function wpse155331_the_permalink( $url ) { if ( is_search() ) { $url = add_query_arg( array( … Read more

Filter keywords from search query

If I understand you correctly you’re not looking for the wp_search_stopwords filter type of solution. So here’s a modification of the great answer by @kaiser that you referred to: /** * Exclude array of words from all search queries in the front-end * * Modification of http://wordpress.stackexchange.com/a/41100/26350 by @kaiser */ add_filter( ‘posts_search’, function( $search, $q … Read more

Combine multiple words in custom meta search query

Split the search query by white space and change ‘compare’ to ‘IN’ to be able to use meta values array: <?php $s = get_search_query(); $s_array = explode( ‘ ‘, $s ); // search query array $args = array( ‘post_type’ = > ‘product’, ‘meta_query’ = > array( ‘relation’ => ‘OR’, array( ‘key’ => ‘vbs_author’, ‘value’ => … Read more