[Support request] Place a Placeholder in search box on the top

Home Forums Support [Support request] Place a Placeholder in search box on the top

Home Forums Support Place a Placeholder in search box on the top

Viewing 15 posts - 1 through 15 (of 16 total)
  • Author
    Posts
  • #608706
    Olivier

    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

    #608714
    David
    Staff
    Customer Support

    Hi Olivier,

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

    #608715
    Olivier

    Hi David,
    It’s OK now ?
    Thank you

    #608717
    David
    Staff
    Customer Support

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

    #608773
    Olivier

    ^^ My site is on development… no access directly

    #608784
    David
    Staff
    Customer Support

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

    #608788
    Olivier

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

    #608795
    David
    Staff
    Customer Support

    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?

    #608800
    Olivier

    I added the code in Functions.php but it does not work.

    error

    https://image.noelshack.com/fichiers/2018/26/2/1530011838-sans-titre-2.png

    #608801
    David
    Staff
    Customer Support

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

    #608811
    Olivier

    Hum OK
    I can give you an access if you want because I limit the plugins πŸ™‚
    Give me your email or other.

    #608825
    David
    Staff
    Customer Support

    You can send login details via the account issue form here:

    https://generatepress.com/contact/

    Please add a link to this post in the details

    #608847
    Olivier

    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…

    #608852
    David
    Staff
    Customer Support

    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.

    #608858
    Olivier

    I use only child theme for all sites πŸ™‚
    Ok for the plugin πŸ™‚

    Thank you very much David

Viewing 15 posts - 1 through 15 (of 16 total)
  • You must be logged in to reply to this topic.