Categorias:

Personalizar o formulário de busca no WordPress

Função para personalizar o formulário de busca no WordPress.

/**
 * personalizar formulário de busca
 * via https://code.difluir.com/
 */
if ( ! function_exists('difluir_custom_search_form') ) :
	function difluir_custom_search_form( $form ) {
		$form = '<form action="'.esc_url(home_url('/')).'" method="get" class="search-form" role="search">';
		
			$form .= '<label>';
				$form .= '<span class="screen-reader-text">'.esc_attr( __('Fazer uma busca', 'difluir') ).'</span>';
				$form .= '<input type="search" name="s" value="" placeholder="'.esc_attr( __('Fazer uma busca', 'difluircode') ).'" class="search-field" />';
			$form .= '</label>';

			$form .= '<button type="submit" class="search-submit">';
				$form .= '<i class="fas fa-search"></i>';
				$form .= '<span class="screen-reader-text">'.esc_attr( __('Buscar', 'difluir') ).'</span>';
			$form .= '</button>';

	    $form .= '</form>';

	    return $form;
	}
endif;

add_filter( 'get_search_form', 'difluir_custom_search_form' );