Wordpress meta key search combined with post title search using WP Query
<p>I am trying to do my own custom search that looks at both meta keys and the post title. </p>

<p>My current code does not limit the results to the category assigned (due to the <code>OR</code> in the query). However by making it <code>AND</code> then search in the meta keys stop working unless the word is in the title.</p>

<p>Is there a way I can search both the titles and meta keys and still limit it to that category?</p>

<p><strong>EDIT :</strong> Just to clarify,
The search im looking to do is the following:</p>

<p><em>Search the search term either in those meta fields or in the post title but all results MUST be in that category.</em></p>

<pre><code>                    function search_title_filter( $where, &amp;$wp_query ) {
                        global $wpdb;
                        if ( $search_title = $_GET['search-in-main-category'] ) {
                            $where .= ' OR ' . $wpdb-&gt;posts . '.post_title LIKE \'%' . esc_sql( $wpdb-&gt;esc_like( $search_title ) ) . '%\'';
                        }

                        return $where;
                    }

                    if(isset($_GET['search-in-main-category'])) {

                        add_filter( 'posts_where', 'search_title_filter', 10, 2 );
                        $search_key = $_GET['search-in-main-category'];
                        $query_args = array(
                            'meta_query' =&gt; array(
                                'relation' =&gt; 'OR',
                                array(
                                    'key' =&gt; 'course_overview',
                                    'value' =&gt; $search_key,
                                    'compare' =&gt; 'LIKE',
                                ),
                            array(
                                'key' =&gt; 'intended_audience',
                                'value' =&gt; $search_key,
                                'compare' =&gt; 'LIKE',
                            ),
                                array(
                                    'key' =&gt; 'method_of_delivery',
                                    'value' =&gt; $search_key,
                                    'compare' =&gt; 'LIKE',
                                ),
                                array(
                                    'key' =&gt; 'course_content/agenda',
                                    'value' =&gt; $search_key,
                                    'compare' =&gt; 'LIKE',
                                )),
                            'product_cat' =&gt; $current_cat_slug,
                            'posts_per_page' =&gt; 50
                            );
                        $search_query = new WP_Query( $query_args );
</code></pre>