pre_get_posts action: Search by post_title and post_content with different search phrase in the same query
Adding the following code in functions.php customize WP search for title only function search_by_title_only( $search, &$wp_query ) { global $wpdb; if ( empty( $search ) ) return $search; // skip processing – no search term in query $q = $wp_query->query_vars; $n = ! empty( $q[‘exact’] ) ? ” : ‘%’; $search = $searchand = ”; … Read more