• I’m having difficulty understanding and finding exactly what the search form searches for. I assumed it searches for tags but after testing it I discovered its only searching for post content after I added the tags directly into the post.

    If thats the case the tags are irrelevant are they not?
    Also if someone does a search term that every post has (eg. word “download”) than that will bring up every single post. It would be much better to have it search tags only for better control of the results.

    Finally it would be nice to have search capable of “and” “or” searches.
    I have searched for the searchform.php but the theme I am using does not appear to have a seperate php page for this. I found a search form in the “general-template.php” FYI this is it here.

    Any help would be hugely appreciated as this has been a problem on my site for a long time and I just cant figure out how all this works.

    ps – I tried a few search plugins but that doesnt seem to solve the issue.
    Thanks

    function get_search_form( $echo = true ) {
    	do_action( 'pre_get_search_form' );
    
    	$format = current_theme_supports( 'html5', 'search-form' ) ? 'html5' : 'xhtml';
    	$format = apply_filters( 'search_form_format', $format );
    
    	$search_form_template = locate_template( 'searchform.php' );
    	if ( '' != $search_form_template ) {
    		ob_start();
    		require( $search_form_template );
    		$form = ob_get_clean();
    	} else {
    		if ( 'html5' == $format ) {
    			$form = '<form role="search" method="get" class="search-form" action="' . esc_url( home_url( '/' ) ) . '">
    				<label>
    					<span class="screen-reader-text">' . _x( 'Search for:', 'label' ) . '</span>
    					<input type="search" class="search-field" placeholder="' . esc_attr_x( 'Search &hellip;', 'placeholder' ) . '" value="' . get_search_query() . '" name="s" title="' . _x( 'Search for:', 'label' ) . '" />
    				</label>
    				<input type="submit" class="search-submit" value="'. esc_attr_x( 'Search', 'submit button' ) .'" />
    			</form>';
    		} else {
    			$form = '<form role="search" method="get" id="searchform" class="searchform" action="' . esc_url( home_url( '/' ) ) . '">
    				<div>
    					<label class="screen-reader-text" for="s">' . _x( 'Search for:', 'label' ) . '</label>
    					<input type="text" value="' . get_search_query() . '" name="s" id="s" />
    					<input type="submit" id="searchsubmit" value="'. esc_attr_x( 'Search', 'submit button' ) .'" />
    				</div>
    			</form>';
    		}
    	}
    
    	$result = apply_filters( 'get_search_form', $form );
    	if ( null === $result )
    		$result = $form;
    
    	if ( $echo )
    		echo $result;
    	else
    		return $result;
    }
  • The topic ‘Search Form – What does it search for?’ is closed to new replies.