WordPress.org

Ready to get started?Download WordPress

Forums

Customizr
[resolved] Move slider location on only one page (7 posts)

  1. voxynn
    Member
    Posted 7 months ago #

    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...?

  2. nikeo
    Member
    Theme Author

    Posted 7 months ago #

    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

  3. voxynn
    Member
    Posted 6 months ago #

    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?

  4. nikeo
    Member
    Theme Author

    Posted 6 months ago #

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

  5. voxynn
    Member
    Posted 6 months ago #

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

  6. nikeo
    Member
    Theme Author

    Posted 6 months ago #

    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

  7. voxynn
    Member
    Posted 6 months ago #

    Perfect @nikeo, thank you very much!

Reply

You must log in to post.

About this Theme

About this Topic

Tags