Wordpress search problems

Discussion in 'PHP' started by SharingEngines, Oct 7, 2012.

  1. #1
    Hi,

    I have a classifieds ads website mxclass(dot)pt

    The problem is when I made a search like "Ipad" retrieves a 452 results.
    Homes, cars... he searches everything. If I have a word like "equipada"
    he search this word because this word is formed "equipada" with the leters Ipad.

    I have the code of the search.php

    Any chance to fix this so search will give more importance to title?
    Or maybe search only for the whole word "Ipad"?

    Thank you in advance for your help!

    $searchTxt = trim( strip_tags( esc_attr( get_search_query() ) ) );
    						$state_append = '';
    						$state = $_GET['cp_state'];
    						if($state != '0') 
    							$state_append = __('-', 'appthemes').' ' . $state;
    						$cat_id =  $_GET['scat'];
    						
    						if ( $searchTxt ==  __('O que procura?','appthemes') || $searchTxt ==  __('[All]','appthemes') ) $searchTxt = '*';
    						if($searchTxt){
    							if($searchTxt == '*') {
    								if($cat = get_term_by('id', $cat_id, 'ad_cat')) {
    									printf( __("Anuncios %s %s ",'appthemes'), $cat->name, $state_append, $wp_query->found_posts ); 
    								} else {
    									printf( __("Anuncios %s ",'appthemes'), $state_append, $wp_query->found_posts ); 
    								}
    							} else {
    								printf( __("Pesquisa de '%s' %s (%s)",'appthemes'), $searchTxt, $state_append, $wp_query->found_posts ); 
    							}
    						}else{
    							$searchTxt = trim( strip_tags( esc_attr( get_search_query() ) ) );
    							printf( __("Pesquisa de '%s' (%s)",'appthemes'), $searchTxt, $wp_query->found_posts ); 
    						}
    						?>
    Code (markup):
     
    SharingEngines, Oct 7, 2012 IP
  2. plussy

    plussy Peon

    Messages:
    152
    Likes Received:
    5
    Best Answers:
    9
    Trophy Points:
    0
    #2
    You need to change the actual search query. I assume that there will be somewhere something like "%SEARCHTERM%" and you need to change it to "% SEARCHTERM %"
     
    plussy, Oct 10, 2012 IP