WordPress.org

Support

Support » Themes and Templates » Adding shortcode to header

Adding shortcode to header

  • Am using the Customizr theme and I love it.
    I’d like to add a shortcode to the header of every page. The shortcode shows 2 buttons – “Add Your Feed” and “Post Your Event”. It’s available with the Front End Submission for with All In One Event Calendar.

    I figure I could use

    <?php echo do_shortcode('[ai1ec_interactive_frontend]'); ?>

    but don’t know how to place it.
    I am using a child theme and have inserted the code to add Search in the header. I’d like to put the shortcode just below that either centred or right aligned.

    Site is at http://thmcec.org.au

    Any help gratefully appreciated.
    Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Theme Author nikeo

    @nikeo

    Hi @billrodgers2013, the hook you might want to use for that is an action hook named ‘__navbar’, example :

    add_action('__navbar' , 'callback_function' , $priority = 40, $number_of_arguments = 1 );

    See some examples of implementations here.
    Bear in mind that you can set the actions order with the priority parameter when declaring a new action on a hook with add_action().
    Hope this helps!

    Thanks for that!
    I ended up using the cod snippet example to add a widget area under the navbar, moved it to the right and then padded it a bit.
    then used Advanced Text widget and entered the php code there.
    Worked like a charm even though Advanced Text Widget would show the buttons if I did the same in a sidebar but they wouldn’t work.

    Possibly a convoluted way to go about it but I now have a widget area up top. If only I could add more widgets and have them side-by-side and not stacked on top.

    Theme Author nikeo

    @nikeo

    I am currently working on an important theme update to make it much easier to add widgets anywhere.
    Thanks for your feedback.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Adding shortcode to header’ is closed to new replies.