[Theme: Thematic] wp_reset_query() has failed me. Now what?
-
I’m making a child theme and I’m trying to do something I thought would be simple: have a slideshow show up on the home page only. Somehow it’s not working. I’ve been searching high and low, but everyone else’s problem is solved by wp_reset_query();
Here’s the code, it’s in my child theme’s functions.php:
function add_slider() { echo do_shortcode('[metaslider id=197]'); } wp_reset_query(); if (is_home() || is_front_page()) { add_action('thematic_belowheader','add_slider','1'); } else { //YOU GET NOTHING! YOU LOSE! GOOD DAY SIR. }
(Yes, all this is between php tags.) This is driving me nuts. I’ve tried a bunch of different variations, including using is_page. But the conditional just won’t work. Minus if and else (ie, just the function and add_action) it works fine, but I don’t want the slider to show up on every page.
I’m a beginner with WP and don’t have much experience with PHP and am deeply confused by this whole “loops! queries! looped queries!” business that people start talking about when I desperately google things like “why wp_reset_query no work? how do I php? why is there this bad?” I just don’t get what’s happening or why this isn’t working. I add a function to echo is_home() below the header and it returns true on the home page, false on the other pages — so if it knows that the home page is the home page, why can’t it execute the conditional?!
I’m going to go work on some nice, gentle CSS stuff before I tear my hair out. Thank you.
- The topic ‘[Theme: Thematic] wp_reset_query() has failed me. Now what?’ is closed to new replies.