Support » Theme: Customizr » Move slider location on only one page

  • Resolved voxynn

    (@voxynn)


    Hi,

    I’d like to move the slider location on only one page. I am using the current code in the functions.php of my child theme:

    <?php add_action ( 'wp_head' , 'place_slider_before_footer' );?>
    <?php
    	function place_slider_before_footer() {
        if ( !tc__f('__is_home') )
            return;
        remove_action( '__after_header' , array( TC_slider::$instance , 'tc_slider_display' ));
        add_action( '__before_footer', array( TC_slider::$instance , 'tc_slider_display' ));
    }

    Additionally, is there a ‘list’ of locations that the slider can be placed? ie, after_header, before_footer, after_featured_pages…?

Viewing 6 replies - 1 through 6 (of 6 total)
  • Hi,
    1) move on only one specific page : you can add a check on the page id in the conditional statement :
    if ( !tc__f('__is_home') || 'ID-OF-THE-PAGE' != get_the_ID() )
    That will apply the change on the page with ‘ID-OF-THE-PAGE’ id only.

    2) Look through the files templates of Customizr index, header, footer, and you’ll find hooks

    Hope this helps

    Hi Nikeo, thanks for the reply. I’ve been trying to do this but it hasn’t been working. I’ve replaced my child functions.php with

    <?php add_action ( 'wp_head' , 'move_my_slider' );?>
    <?php
    	function move_my_slider() {
        if ( !tc__f('__is_home') || 'page-id-13' != get_the_ID() )
            return;
        remove_action( '__after_header' , array( TC_slider::$instance , 'tc_slider_display' ));
        add_action( '__header', array( TC_slider::$instance , 'tc_slider_display' ));
    }

    in order to move the slider on this page http://scottishtreasurehunts.com/teambuilding/ but with no success. Could someone give me a pointer as to where my coding error is?

    Hi @voxynn, replace 'page-id-13' by 13 and you should be good!
    Thanks

    Hi @nikeo, sorry to be a bother but that isn’t working either. Is there anything that could be stopping it from moving?

    Hi, there was another error in the previous code. This one is working :

    add_action ( 'wp_head' , 'move_my_slider' );
    function move_my_slider() {
        if ( tc__f('__is_home') || 13 != get_the_ID() )
            return;
        remove_action( '__after_header' , array( TC_slider::$instance , 'tc_slider_display' ));
        add_action( '__header', array( TC_slider::$instance , 'tc_slider_display' ));
    }

    Replace __header hook by any other you need.
    Cheers

    Perfect @nikeo, thank you very much!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Move slider location on only one page’ is closed to new replies.