this is my first time working on wordpress, so far im doing well, but i want to customize the Search. I need to change the way the theme property search work, the search look at title and content on property page but i want to search only by title. this is the search code. can anyone help me trough?

if( !function_exists('houzez_property_search_2') ) {
function houzez_property_search_2($search_query)
{

    $tax_query = array();
    $meta_query = array();
    $allowed_html = array();
    $keyword_array = '';

    $keyword_field = houzez_option('keyword_field');

    $search_location = isset($_GET['search_location']) ? esc_attr($_GET['search_location']) : false;
    $use_radius = 'on';
    $search_lat = isset($_GET['lat']) ? (float)$_GET['lat'] : false;
    $search_long = isset($_GET['lng']) ? (float)$_GET['lng'] : false;
    $search_radius = isset($_GET['radius']) ? (int)$_GET['radius'] : false;

    $search_query = apply_filters('houzez_radius_filter', $search_query, $search_lat, $search_long, $search_radius, $use_radius, $search_location);

    if (isset($_GET['keyword']) && $_GET['keyword'] != '') {
        if ($keyword_field == 'prop_address') {
            $meta_keywork = esc_html(wp_kses($_GET['keyword'], $allowed_html));
            $address_array = array(
                'key' => 'fave_property_map_address',
                'value' => $meta_keywork,
                'type' => 'CHAR',
                'compare' => 'LIKE',
            );

            $street_array = array(
                'key' => 'fave_property_address',
                'value' => $meta_keywork,
                'type' => 'CHAR',
                'compare' => 'LIKE',
            );

            $zip_array = array(
                'key' => 'fave_property_zip',
                'value' => $meta_keywork,
                'type' => 'CHAR',
                'compare' => '=',
            );

            $propid_array = array(
                'key' => 'fave_property_id',
                'value' => $meta_keywork,
                'type' => 'CHAR',
                'compare' => '=',
            );

            $keyword_array = array(
                'relation' => 'OR',
                $address_array,
                $street_array,
                $propid_array,
                $zip_array
            );

        } else if ($keyword_field == 'prop_city_state_county') {
            $taxlocation[] = sanitize_title(esc_html(wp_kses($_GET['keyword'], $allowed_html)));

            $_tax_query = Array();
            $_tax_query['relation'] = 'OR';

            $_tax_query[] = array(
                'taxonomy' => 'property_area',
                'field' => 'slug',
                'terms' => $taxlocation
            );

            $_tax_query[] = array(
                'taxonomy' => 'property_city',
                'field' => 'slug',
                'terms' => $taxlocation
            );

            $_tax_query[] = array(
                'taxonomy' => 'property_state',
                'field' => 'slug',
                'terms' => $taxlocation
            );
            $tax_query[] = $_tax_query;

        } else {
            $keyword = trim($_GET['keyword']);
            if (!empty($keyword)) {
                $search_query['s'] = $keyword;
            }
        }
    }

thanks!

Read more here: Houzez property search (WP) search title only


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: