• Hello,

    How do I modify this in functions.php

    add_action ( 'wp_head' , 'place_slider_before_footer' );
    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' ));
    }

    To have the home page text, then the slider then the three featured pages icons on my main page (which isn’t my post index). i.e. what is the text box (what is there when I go to edit page then update) called in the functions.php.

    To clarify…I want the page text under the header and menu, then the slider, then the three featured pages thing above the footer….but only on my home page.

Viewing 13 replies - 1 through 13 (of 13 total)
  • Thread Starter sciwebdesign

    (@sciwebdesign)

    I got that as a fix for putting the slider above the footer. I want a different order. Only for the home page though.

    Thread Starter sciwebdesign

    (@sciwebdesign)

    I’ve tried.

    add_action ( 'wp_head' , 'place_slider_before_featured_pages' );
    function place_slider_before_featured_pages() {
        if ( !tc__f('__is_home') )
            return;
        remove_action( '__after_header' , array( TC_slider::$instance , 'tc_slider_display' ));
        add_action( '__before_featured_pages', array( TC_slider::$instance , 'tc_slider_display' ));
    }

    With no joy.

    Help pretty please.

    That won’t work, as there is no “__before_featured_pages” hook.

    Let’s think this through (thinking as I’m writing). You currently have:
    -header
    -slider
    -features
    -text
    -footer

    You want:
    -header
    -text
    -slider
    -features
    -footer

    So the only thing that needs moving is the text. It needs to be unhooked from where it is and placed after the header. We should be able to use Nicolas’ technique for that.

    So first we need to find out where the text is hooked and what it’s called. This is a page, so looking in class-content-page.php should give us a clue.

    Yup. There it is:

    class TC_page {
    
        //Access any method or var of the class with classname::$instance -> var or method():
        static $instance;
    
        function __construct () {
            self::$instance =& $this;
            //pages templates
            add_action ( '__loop'                       , array( $this , 'tc_page_content' ));
        }

    So the function is tc_page_content and it’s inside the TC_page class — don’t ask me what that means, I’m just reading what the code says! ?? — and it’s hooked on __loop, which is the WordPress main post/page engine.

    So, taking the first code you pasted from this snippet and extrapolating with the info that we’ve just gained, we get:

    //we hook the code on the wp_head hook, this way it will be executed before any html rendering.
    add_action ( 'wp_head' , 'move_my_front_page_text');
    function move_my_front_page_text() {
        //we unhook the content
        remove_action( '__loop' , array( TC_page::$instance , 'tc_page_content' ));
    
        //we re-hook the content. Check the priority here : set to 0 to be the first in the list of different actions hooked to this hook
        add_action( '__after_header' , array( TC_page::$instance , 'tc_page_content' ), 0);
    }

    And whaddayaknow, it works! Looks a bit odd, though. You’ll need to style the text.

    Thread Starter sciwebdesign

    (@sciwebdesign)

    Superb. I am very grateful. I will try it.

    Bloody hate php.

    Thread Starter sciwebdesign

    (@sciwebdesign)

    That works for you?

    Not here. The main text has disappeared completely.

    This isn’t the site I am doing it for…I just installed the same versions on my site before adding it to the client I am working for’sDummy site here.

    Thread Starter sciwebdesign

    (@sciwebdesign)

    Do I add it to index.php rather than functions.php?????

    You add it to functions.php in your child theme, not the parent’s. Child theme details here.

    Thread Starter sciwebdesign

    (@sciwebdesign)

    Done the child theme, edited functions.php in the child theme and it still doesn’t work.

    //we hook the code on the wp_head hook, this way it will be executed before any html rendering.
    add_action ( 'wp_head' , 'move_my_front_page_text');
    function move_my_front_page_text() {
        if ( !tc__f('__is_home') )
            return;
            remove_action( '__loop' , array( TC_page::$instance , 'tc_page_content' ));
        add_action( '__after_header' , array( TC_page::$instance , 'tc_page_content' ), 0);
    }

    And then the content just goes missing…

    I can show you the site now. It is here.

    ?? any ideas? They want the text above the slider on the home page only.

    The code I suggested above was:

    //we hook the code on the wp_head hook, this way it will be executed before any html rendering.
    add_action ( 'wp_head' , 'move_my_front_page_text');
    function move_my_front_page_text() {
        //we unhook the content
        remove_action( '__loop' , array( TC_page::$instance , 'tc_page_content' ));
    
        //we re-hook the content. Check the priority here : set to 0 to be the first in the list of different actions hooked to this hook
        add_action( '__after_header' , array( TC_page::$instance , 'tc_page_content' ), 0);
    }

    and not what you have posted here.

    Thread Starter sciwebdesign

    (@sciwebdesign)

    Thread Starter sciwebdesign

    (@sciwebdesign)

    Tried.

    <?php
    /**
    * //we hook the code on the wp_head hook, this way it will be executed before any html rendering.
    add_action ( 'wp_head' , 'move_my_front_page_text');
    function move_my_front_page_text() {
        //we unhook the content
        remove_action( '__loop' , array( TC_page::$instance , 'tc_page_content' ));
    
        //we re-hook the content. Check the priority here : set to 0 to be the first in the list of different actions hooked to this hook
        add_action( '__after_header' , array( TC_page::$instance , 'tc_page_content' ), 0);
    }
    */

    and

    <?php
    /**
    * This is where you can copy and paste your functions !
    */
    
    //we hook the code on the wp_head hook, this way it will be executed before any html rendering.
    add_action ( 'wp_head' , 'move_my_front_page_text');
    function move_my_front_page_text() {
        //we unhook the content
        remove_action( '__loop' , array( TC_page::$instance , 'tc_page_content' ));
    
        //we re-hook the content. Check the priority here : set to 0 to be the first in the list of different actions hooked to this hook
        add_action( '__after_header' , array( TC_page::$instance , 'tc_page_content' ), 0);
    }

    The second one gets rid of the text box completely. The first method does nothing.

    I HATE PHP.

    I can understand it hating you back if you throw random asterisks and slashes at it ??

    Make the whole child-theme functions.php file look like this:

    <?php
    //we hook the code on the wp_head hook, this way it will be executed before any html rendering.
    add_action ( 'wp_head' , 'move_my_front_page_text');
    function move_my_front_page_text() {
        //we unhook the content
        remove_action( '__loop' , array( TC_page::$instance , 'tc_page_content' ));
    
        //we re-hook the content. Check the priority here : set to 0 to be the first in the list of different actions hooked to this hook
        add_action( '__after_header' , array( TC_page::$instance , 'tc_page_content' ), 0);
    }

    No extras; just that.

    Then get yourself a decent text editor like SublimeText, which shows up errors like those in the code you posted in an instant. Then you’ll grow to love php ??

    Check you also have a home page called “home” defined, with your front page set up to point to it…

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Change order of front page..how?’ is closed to new replies.