• Hello there,

    I have “General & Basics” “Search in Title” ON, and all the others turned OFF (content, excerpts etc).

    Problem is, searches insists on still looking inside product descriptions and list them in the results page (but not in the search suggestion though)

    I already removed the shortcode from the previous plugin search and deactivated it.
    How can I make it stop searching in product descriptions?

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter gabrielcupim

    (@gabrielcupim)

    by the way, I tried this code I found, but it doesn’t work properly.
    It ruins my “AND” search logic, and still searches within excerpts.

    ex: searching for “Uncharted 3” gets me a lots of products with the character “3” which are in excerpts

    function ni_search_by_title_only( $search, &$wp_query ){
    global $wpdb;
    if ( empty( $search ) )
    return $search;
    $q = $wp_query->query_vars;
    $n = ! empty( $q[‘exact’] ) ? ” : ‘%’;
    $search =
    $searchand = ”;
    foreach ( (array) $q[‘search_terms’] as $term ) {
    $term = esc_sql( like_escape( $term ) );
    $search .= “{$searchand}($wpdb->posts.post_title LIKE ‘{$n}{$term}{$n}’)”;
    $searchand = ‘ AND ‘;
    }
    if ( ! empty( $search ) ) {
    $search = ” AND ({$search}) “;
    if ( ! is_user_logged_in() )
    $search .= ” AND ($wpdb->posts.post_password = ”) “;
    }
    return $search;
    }
    add_filter( ‘posts_search’, ‘ni_search_by_title_only’, 500, 2 );

    ===============
    The code above is not running at the moment.

    Plugin Author wpdreams

    (@wpdreams)

    Hi,

    If you are reffering to the results page results (not the live search), then make sure that the search override feature is activated as well: https://i.imgur.com/q1auFxi.png

    Best,
    Ernest M.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Don’t search in product description’ is closed to new replies.