Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter oacassidy

    (@oacassidy)

    Found work-around. What I did was find the register_nav_menus function in the mobile parent theme (it’s in functions.php) and copy that into the functions.php file of the child theme for the desktop version. Lucky for me, they use different identifiers for the primary menu. (Although the same description, but changing the description for clarity doesn’t seem to have messed up the mobile theme’s menus.) Then when I went into Appearance >> Menus, the mobile theme slots showed up there and I was able to assign the appropriate menus to them, which show up on the mobile site. Haven’t completely wrapped my head around why that works, but apparently it does.

    Thread Starter oacassidy

    (@oacassidy)

    Solved it myself! Actually almost started crying with relief. This is for work and I’m at work so that was weird.

    On the off chance anyone ever finds this thread, here’s what was wrong and how I fixed it:

    In Conditional Tags, you’ll notice this warning:

    Warning: You can only use conditional query tags after the posts_selection action hook in WordPress (the wp action hook is the first one through which you can use these conditionals). For themes, this means <b>the conditional tag will never work properly if you are using it in the body of functions.php, i.e. outside of a function.</b>

    Which was further clarified by the people in this thread, where it is pointed out that because functions.php loads first, is_home() and is_front_page() will return false if run at the time functions.php is loaded because the page doesn’t know if it’s the home page yet or not.

    So basically I needed an extra layer so that the function and conditional add_action above don’t get loaded until after the page knows it’s the home page. This is the final product:

    function add_slider() {
    	echo do_shortcode('[metaslider id=197]');
    }
    function really_add_slider() {
    	if (is_home() || is_front_page()) {
    		add_action('thematic_belowheader', 'add_slider','1');
    	} else {
    		//YOU GET NOTHING. YOU LOSE. GOOD DAY SIR.
    	}
    }
    add_action('posts_selection','really_add_slider');

    MIRACULOUS. There’s probably a better, more efficient way to do this, but this is what I came up with and it WORKS YOU GUYS IT TOTALLY WORKS. No wp_reset_query needed.

Viewing 2 replies - 1 through 2 (of 2 total)