Add search bar to breadcrumbs

  • Michal
    Michal
    Senior Member 118 points
    April 24, 2015 at 9:36 am

    Hi,

    I want add search to the right in breadcrumbs and replace it with social icons.
    I was looking at https://www.premiumpress.com/docs/#hooks_layout but have no idea on how and where to use them.
    See image
    function hook_breadcrumbs($c){ return apply_filters(‘hook_breadcrumbs’, $c); }
    function hook_breadcrumbs_func($c){ return apply_filters(‘hook_breadcrumbs_func’, $c); }
    function hook_breadcrumbs_before(){ do_action(‘hook_breadcrumbs_before’); }
    function hook_breadcrumbs_after(){ do_action(‘hook_breadcrumbs_after’); }

    Attachments:
    You must be logged in to view attached files.

  • Josh
    Super Guru 13,875 points
    April 24, 2015 at 12:52 pm

    Hello Michal
    Try this in your Child Theme functions.php
    [code title=””]
    add_filter(‘hook_breadcrumbs’,’search_input’);
    function search_input(){
    return’
    <form action=”https://mysiteurl/BT/&#8221; method=”get” id=”wlt_searchbox_form”>
    <div class=”wlt_searchbox clearfix”>
    <div class=”inner”>
    <div class=”wlt_button_search”><i class=”glyphicon glyphicon-search”></i></div>
    <input name=”s” placeholder=”Search” type=”search”>
    </div>
    </div>
    </form>
    ‘;
    }
    [/code]

  • Michal
    Michal
    Senior Member 118 points
    April 28, 2015 at 4:50 pm

    Hi Josh,
    thank you for your help, unfortunatelly this didn’t work as it should but you are close 🙂
    Your code replaced breadcrumbs totally, moved down in line and I just wanted to replace social icons. Can you come up with other solution, please?
    Please see images.

    Attachments:
    You must be logged in to view attached files.

  • Josh
    Super Guru 13,875 points
    April 28, 2015 at 6:05 pm

    Replace the above code with this
    [code title=””]
    add_filter(‘hook_breadcrumbs’,’search_input’);
    function search_input(){
    return’
    <form action=”https://localhost/wordpress/BT/&#8221; method=”get” id=”wlt_searchbox_form” class=”clearfix”>
    <div class=”wlt_searchbox clearfix”>
    <div class=”inner”>
    <div class=”wlt_button_search”><i class=”glyphicon glyphicon-search”></i></div>
    <input name=”s” placeholder=”Search” type=”search”>
    </div>
    </div>
    </form><br />
    ‘;
    }
    [/code]

  • Michal
    Michal
    Senior Member 118 points
    April 28, 2015 at 7:54 pm

    Thank you Josh for your ongoing support!!
    Search bar is now in breadcrumbs however left side breadcrumbs (cart and currency) now have disappeared even if I have them activated in backend.
    Am I doing something wrong?
    Screen attached

    Attachments:
    You must be logged in to view attached files.
  • Michal
    Michal
    Senior Member 118 points
    April 28, 2015 at 8:12 pm

    Also I replaced one line as the one I got didnt proceed any search.
    Hope will work

    from
    <form action=”https://localhost/wordpress/BT/&#8221; method=”get” id=”wlt_searchbox_form” class=”clearfix”>

    to
    <form action=”https://mysite.com/?s=/”&#8221; method=”get” id=”wlt_searchbox_form” class=”clearfix”>


  • Josh
    Super Guru 13,875 points
    May 1, 2015 at 6:52 am

    The cart and currency are part of the breadcrumb and since we are hooking into the breadcrumb the cart and currency will not be displayed

    This reply was awarded the best answer by the topic poster.
  • Michal
    Michal
    Senior Member 118 points
    May 2, 2015 at 8:44 am

    That is too bad but thanks for explain Josh and for your time and effort.
    Really appreciate your help Josh, thank you.

  • Mark
    Mark
    Titan 733 points
    May 2, 2015 at 11:57 am

    The cart and currency are part of the breadcrumb and since we are hooking into the breadcrumb the cart and currency will not be displayed

    That is not fully correct. Even though you are hooking into the breadcrumb function, it does not necessarily mean that you have to overwrite it. You can easily ‘filter’ the breadcrumb function content and place your ‘search’ part before, after or even in-between existing content. Moreover, the cart and currency are not part of the core breadcrumbs.

    Mark

  • Michal
    Michal
    Senior Member 118 points
    May 5, 2015 at 10:42 am

    Thanks for your opinion Mark.
    Would you be so good and share example filter?
    I never used this before.


  • Josh
    Super Guru 13,875 points
    May 5, 2015 at 11:20 am

    Thanks for sharing Mark 🙂

Viewing 11 posts - 1 through 11 (of 11 total)

New Business Themes for WordPress 2020

Start your new website today!

View Business Themes