This is searchable archive of our old support forums, which operated from 2012 - 2016. To find out how to get support for your current theme, please visit our support page.

How to place a search box in the header between logo and social buttons

  • Creator
    Topic
  • #11371
    oledjur
    Participant

    Hi
    I am trying to place a search box in the header between logo and social buttons.

    In the child theme functions.php I have placed:

    remove_all_actions( 'themeblvd_header_addon' );
    add_action(‘themeblvd_header_addon’, ‘get_search_form’);

    just before:

    require_once( get_template_directory() . '/framework/themeblvd.php' );

    But the search form doesn’t show: http://www.go2learn.dk/

    Any ideas?

    Best regards
    Ole

Viewing 8 replies - 1 through 8 (of 8 total)
  • Author
    Replies
  • #11380
    Jason Bobich
    Keymaster

    Hello Ole,

    You’ve almost got it; there’s just a couple things I’m noticing.

    1) For whatever reason, starting in WordPress 3.6 when you hook get_search_form() directly to an action, it doesn’t output anything. I honestly haven’t taken the time to investigate it and can’t tell you why.

    Anyway, so you’d need to create a function that you hook where you call get_search_form() within. For example —

    function my_header_addon() {
    	get_search_form();
    }
    remove_all_actions( 'themeblvd_header_addon' );
    add_action('themeblvd_header_addon', 'my_header_addon');

    2) And in your child theme, all of your action hooks should to go after this line:

    require_once( get_template_directory() . '/framework/themeblvd.php' );

    For example, if you were to do this before:

    remove_all_actions( 'themeblvd_header_addon' );

    You’re not removing anything from “themeblvd_header_addon” because nothing has been added yet. Including the framework above is what runs the theme’s functionality and sets everything into action. The reason for this is because WordPress loads the functions.php of your child theme before the functions.php of the parent theme.

    #11429
    oledjur
    Participant

    Hi Jason,
    Thank you so much. It works now. My only problem now is that the social buttons doesn’t show. Do I have to add them the same way as the search form?
    Best regards
    Ole

    #11437
    Jason Bobich
    Keymaster

    The social buttons are hooked to the “themeblvd_header_addon” (and are the only thing hooked there by the theme). So, looking at your code which line do you think you’d get rid of so you’re not removing the social icons? 😉

    #11462
    oledjur
    Participant

    Got it;-)
    Thanx

    #11665
    collicutt
    Participant

    If I adjust some of the code would this work for putting a country link (instead of search box) Its an image with a url link .
    Or do I need to to do something totally different?

    collicutt

    Ps love this template, great suport too

    #11677
    Jason Bobich
    Keymaster

    If I adjust some of the code would this work for putting a country link (instead of search box) Its an image with a url link .
    Or do I need to to do something totally different?

    This is essentially just a basic example of how to use action hooks. You could output anything you want there, really. So, just experiment and have fun with it in your child theme’s functions.php

    function my_header_addon() {
    	// Do whatever ...
    }
    remove_all_actions( 'themeblvd_header_addon' );
    add_action('themeblvd_header_addon', 'my_header_addon');

    Please see the following articles:

    http://dev.themeblvd.com/tutorial/actions/

    http://dev.themeblvd.com/tutorial/primary-framework-action-hooks/

    #14309
    kipbiz
    Participant

    I’ve added the code above to the child theme functions.php. It is Akita 2.0.3. The Search box does show in the header area. But it is not part of the class themeblvd_header_addon. It appears as a separate DIV. How can I make it stay in the header-addon DIV?

    Here it is in Firebug:

    Thank you.

    #14318
    Jason Bobich
    Keymaster

    I’ve added the code above to the child theme functions.php. It is Akita 2.0.3. The Search box does show in the header area. But it is not part of the class themeblvd_header_addon. It appears as a separate DIV. How can I make it stay in the header-addon DIV?

    For everything currently hooked into the theme that isn’t part of the core framework, see /includes/theme-functions.php of the theme. You’ll find a function called akita_header_top(). That’s what the theme hooks to to the themeblvd_header_addon hook by default and where this HTML structure comes from.

    So, here’s one possible approach — You could copy that function to your child theme’s functions.php, change its name to something else, then make your modifications to it, and hook it in.

    function my_header_addon() {
    	// Your modified copy of the akita_header_addon function in here
    }
    remove_action( 'themeblvd_header_addon', 'akita_header_addon' );
    add_action('themeblvd_header_addon', 'my_header_addon');
Viewing 8 replies - 1 through 8 (of 8 total)
  • The forum ‘Akita Responsive WordPress Theme’ is closed to new topics and replies.