Archived topic
searchbar only on desktop
11 replies · Started by Philippe on May 12, 2022
Hi,
I want to add searchbar on header after website logo and just before social logos (right on header)
But only on home and only on desktop
how can i do it?
Many thanks
Phil
Here is the website : https://comment-stocker.fr
Hi there,
you can use a Block Element found in Appearance > Elements.
You want the Element Type of Hook
https://docs.generatepress.com/article/block-element-hook/
Add you Search Block to its content.
Select the Hook: after_logo
Set the Display Rules > Location to: Front Page
Hi
I have paste this html code to its content (the content is html only), but not works :
<!-- wp:search {"label":"Rechercher","showLabel":false,"placeholder":"Rechercher…","buttonText":"Rechercher","buttonUseIcon":true} /-->
think i don't have made the right thing
what can i do more please ?
Thks
Phil
OK if you're using the classic editor then.
1. DELETE the hook you created.
2. Create a New Hook Element:
https://docs.generatepress.com/article/hooks-element-overview/
3. In the text area add:
<?php get_search_form(); ?>
4. Set the Hook to: generate_after_logo
5. Check the Execute PHP option.
6. Set the Display Rules > Location to: Front Page
Hi
Thanks for your response, but no way, it don't works too.
Also, i don't understand your sentence "OK if you’re using the classic editor then.", i don't have another choice, on the hook editor there is only this choice ! (i use gutenberg on all the website, without classic editor plugin).
Do i have a bug on my installation ?
Just for finish my entire demand, i wan't also that the search bar is only displayed on desktop.
Many thanks,
Phil
David's suggested using block element which uses Gutenberg at first, but it seems you didn't follow, you tried to copy and paste the HTML, that's why David thought you were using classic editor.
If you are NOT using classic editor plugin, please try to follow David's first suggestion: https://generatepress.com/forums/topic/searchbar-only-on-desktop/#post-2218303
yes but where i can use the element block gutenberg, on the hook editor there is no place to choose it and the hook element editor can accept only code ?
… And the search bar don't appear too, have you the solution on my problem?
Go to appearance > elements, when you create a new element, choose block:
https://docs.generatepress.com/article/block-element-overview/
don't works too
Can you describe how didn't it work?
No sorry all it's ok now many thanks
best regards
Phil
Very glad to hear that :)