Archived topic
Search box for blog post
9 replies · Started by Giacomo on January 20, 2018
Hello, i need to add search box for BLOG POST in GP hooks
like this

or like this

can someone help me with the code please?
Hi there,
Try:
<?php if ( is_single() ) {
get_search_form();
} ?>
okay, i try but don't work
Did you check Execute PHP?
I just tried the exact code in hooks and it worked.
i try to copy the code in hook

but search box don't appears

Which hook is that? can you link me to the page?
i try copy the code in:
- after header hook
and
- inside content container hook
That's the main blog page, not single posts.
Try this instead:
<?php if ( is_home() ) {
get_search_form();
} ?>
More info here if you are interested: https://docs.generatepress.com/article/using-hooks-conditional-tags/
sorry man,
now it works perfectly but if I need to view this in all the pages?
To show on all pages? You can just remove the conditional tag:
get_search_form();