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 slider on the header of every page

  • Creator
    Topic
  • #9198
    adagio
    Participant

    Hello.

    I need to place a slider on the header of the theme and i want it on any page (blog and pages)
    Is there a php code to place in the header.php file of word press ?

Viewing 8 replies - 1 through 8 (of 8 total)
  • Author
    Replies
  • #9199
    adagio
    Participant

    Sorry if I am not being clear. In fact i just need to place a slider on Every page and i would like to know if it is possible to have a php code to place on wordpress php files without (perhaps) using the builder.

    #9200
    adagio
    Participant

    To be more precise i would like to insert the slider just under the navigation bar and i don’t want it to disappear in any of my pages.
    I even want my slider in any single post page.
    I have managed to place the slider in all pages using the layout builder but it vanishes in a single post page. That is why I was thinking of placing the slider in the wordpress header.php file but I do not know if it is possible to insert it with a php code.
    I hope I made myself understood as i am not english.

    #9206
    Jason Bobich
    Keymaster

    Hello,

    Here’s one way — From the functions.php file of your child theme, you’d just hook to the appropriate action hook.

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

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

    For example —

    function my_header_after() {
        echo do_shortcode('[slider id="my-slider"]');
    }
    add_action( 'themeblvd_header_after', 'my_header_after' );

    http://codex.wordpress.org/Function_Reference/do_shortcode

    Note: I can’t promise you that styling-wise, a slider placed there is going to look perfect, as this is not the theme’s intention and customization you’re making.

    #9209
    adagio
    Participant

    Thanks jason. I’ll try this.
    Other wise isn’t there a cool php code i could insert in the header.php ?

    It would also be great if we were able to customize a single post page with your builder.

    #9211
    Jason Bobich
    Keymaster

    You could technically do something similar to above in your header.php —

    <?php echo do_shortcode('[slider id="my-slider"]'); ?>

    But I would suggest not editing main template files like header.php because these files change quite often with theme updates. This is why we provide so many action hooks. When you hook to “themeblvd_header_after” for example as I showed previously, you essentially are placing a piece of code into header.php, if you want to think of it like that.

    #9215
    adagio
    Participant

    the thing is i have created a copy of the header.php file in the Child Theme as i had to add some addition html divs in order to place another small static banner.

    Anyway Thks a lot Jason !

    #9217
    Jason Bobich
    Keymaster

    the thing is i have created a copy of the header.php

    That will work, but just a fair warning, your site will break after the next update. 😉

    To accomplish the exact same thing in a much safer way, you would just do this from your functions.php

    function my_header_after() {
        echo '<div class="whatever">';
        echo '<div class="whatever-else">';
        echo do_shortcode('[slider id="my-slider"]');
        echo '</div>';
        echo '</div>';
    }
    add_action( 'themeblvd_header_after', 'my_header_after' );

    Or this —

    function my_header_after() {
        ?>
        <div class="whatever">
            <div class="whatever-else">
                <?php echo do_shortcode('[slider id="my-slider"]'); ?>
            </div>
        <div>
        <?php
    }
    add_action( 'themeblvd_header_after', 'my_header_after' );

    … All doing the same thing. Trust me, take a moment to understand the basics of action hooks in WordPress and creating basic PHP functions. You’ll be able to do so much more moving forward.

    #9242
    adagio
    Participant

    Once again a BIG THANK YOU for helping.
    As you noticed I am not very confortable with the action hooks but clearly I’ am going to follow your advice 🙂

Viewing 8 replies - 1 through 8 (of 8 total)
  • The forum ‘Akita Responsive WordPress Theme’ is closed to new topics and replies.