[Support request] Search box for blog post

Home Forums Support [Support request] Search box for blog post

Home Forums Support Search box for blog post

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #475484
    Giacomo

    Hello, i need to add search box for BLOG POST in GP hooks

    like this

    Search box

    or like this

    Search box

    can someone help me with the code please?

    #475720
    Leo
    Staff
    Customer Support

    Hi there,

    Try:

    <?php if ( is_single() ) { 
        get_search_form();
    } ?>
    #476114
    Giacomo

    okay, i try but don’t work

    #476244
    Leo
    Staff
    Customer Support

    Did you check Execute PHP?

    I just tried the exact code in hooks and it worked.

    #476254
    Giacomo

    i try to copy the code in hook

    Test

    but search box don’t appears

    test

    #476263
    Leo
    Staff
    Customer Support

    Which hook is that? can you link me to the page?

    #476267
    Giacomo

    i try copy the code in:
    – after header hook
    and
    – inside content container hook

    https://grement.com/

    #476635
    Leo
    Staff
    Customer Support

    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/

    #476798
    Giacomo

    sorry man,
    now it works perfectly but if I need to view this in all the pages?

    #477028
    Leo
    Staff
    Customer Support

    To show on all pages? You can just remove the conditional tag:
    get_search_form();

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