Site logo

Archived topic

Place a Placeholder in search box on the top

15 replies · Started by Olivier on June 26, 2018

Viewing posts 1–15 of 16

Hi
I have test this topic without succes :
https://docs.generatepress.com/article/generate_navigation_search_output/
https://docs.generatepress.com/article/generate_search_placeholder/

I have test this too :

add_filter( 'generate_navigation_search_output', 'woo_placeholder_search' );
function woo_placeholder_search() { 
	return __( 'Ajouter au devis', 'woocommerce' );
}

Can you help me ?

Placeholder

Image : https://image.noelshack.com/fichiers/2018/26/2/1530005743-placeholder.png

Thank you :)

Olivier

Hi Olivier,

the link you have provided does not work, can you edit the original topic and provide a working one?

Hi David,
It's OK now ?
Thank you

Hi Olivier its not the URL doesn't look correct its just dev.dev

^^ My site is on development... no access directly

What is it you are trying to do? Is it adding a Placeholder? Or Filtering the Search?

No just adding a Placeholder in the search bar, a text : "Que cherchez-vous ?"

Ok, so the code should look like this:

add_filter( 'generate_navigation_search_output', 'tu_navigation_search_placeholder' );
function tu_navigation_search_placeholder() {
	printf( 
		'<form method="get" class="search-form navigation-search" action="%1$s">
			<input type="search" placeholder="Que cherchez-vous ?" class="search-field" value="%2$s" name="s" title="%3$s" />
		</form>',
		esc_url( home_url( '/' ) ),
		esc_attr( get_search_query() ),
		esc_attr_x( 'Search', 'label', 'generatepress' )
	);
}

You can add this to your child theme functions or use the Code Snippets Plugin link provided in here:

https://docs.generatepress.com/article/adding-php/

Add the code (and activate if using the plugin).

If it still isn't showing then can your use the Browser Inspector on the search bar when its open and inspect the code in the console. And see whether the placeholder is correct?

hmm it's difficult to assess without access to the site. Could you try adding the code using the Code Snippets plugin?

Hum OK
I can give you an access if you want because I limit the plugins :)
Give me your email or other.

David it's work !

I must use the Editor in WordPress to modify the Functions.php, if I use the FTP and Notepad++ and save it, it's don't work. I don't know why... maybe caracters invisible...

Hi Olivier,

glad to hear that, but unless you are using a child theme then it not recommended to directly edit the Function files, any changes will be lost when the theme is updated.

The Code Snippets plugin is really good, many GP users including myself use this for a lot of builds.

I use only child theme for all sites :)
Ok for the plugin :)

Thank you very much David

This archived topic is closed to new replies.