I'm using woo themes and trying to use some woo hooks to hook into the index.php file from my child theme.

I'm using the following code:

function content_woo_main_before() {
    if  (is_home() || is_front_page()) {
add_action('woo_main_before', 'content_woo_main_before', 15 );

function content_woo_main_after() {
    if  (is_home() || is_front_page()) {
add_action('woo_main_after', 'content_woo_main_after', 15 );

The strange thing about this is that the first function loads as it should on the home page, but the second one does not. I tried a few things like changing the order that the functions are run, changing the names, I tried wrapping the functions in the conditional statement. Nothing worked.

Am I doing something wrong here?

I found a few other posts that had something similar to this, about how the is_home() won't work in functions.php, because it runs before we know if we're on the home page, but that wouldn't explain why the first function works properly, and the second one doesn't.

Anyone have any ideas?


So, based on the feedback I've gotten, I've updated the following using get_template_part()


here's the code:

function content_woo_main_before() {
    echo 'is_home1 =' . is_home();
    echo 'is_front_page1 = ' .  is_front_page();

    if  (is_home()) {
        get_template_part('home', 'news');
add_action('woo_main_before', 'content_woo_main_before', 20 );

function content_woo_main_after() {
    echo 'is_home2 = ' . is_home() . '<br />';
    echo 'is_front_page2 = ' .  is_front_page();
    if  (is_front_page()) {
        echo 'is_home3 =' . is_home();
        echo 'is_front_page3 = ' .  is_front_page();
        get_template_part('home', 'after');
add_action('woo_main_after', 'content_woo_main_after', 21 );

Here's what I don't get. If I have both of these functions with both using is_home() || is_front_page(), the first returns "1", but the second functions return nothing at all. So, "is_home1" returns 1, "is_front_page1" returns 1, therefore it's true and the content loads. However, "is_home2" and "is_front_page2" returns nothing, the conditional statement returns false, and the content doesn't load.

I tried various numbers for the loading sequence, but that didn't do anything. I put some crazy long number and it still didn't return true.

What's also weird is that if I take out the first function (woo_main_before), the second one works as expected. Only when both of them are there does the second one not work.

I can't seem to find anyone else with this problem online. I have no idea what's wrong.

Any ideas?

  • Have you tried this with define('WP_DEBUG', true); in wp-config.php? And also make sure that something is not wrong with file home-news-after.php than the home-news.php. Sep 27, 2013 at 5:39
  • Try to debug using echo is_home() and echo is_front_page() for home page and other page. Hope this will help you to resolve the issue. Also enable debug.
    – Manish
    Sep 27, 2013 at 6:03
  • 3
    I strongly suggest you use get_template_part() instead of your include() Also I'd make sure you're not having a priority conflict. codex.wordpress.org/Function_Reference/get_template_part
    – Brooke.
    Sep 27, 2013 at 7:02
  • I thought about the priority conflict too. I had one set as 16, but that didn't do anything. Sep 27, 2013 at 20:21
  • @MayeenulIslam, debug is on, but it's only giving me one error that has to do with something unrelated (at least I think). Also, there is only a few closing divs on that page. No PHP or any other code that would cause the page to not load. Oct 1, 2013 at 1:55

1 Answer 1


It turns out that the first hook function, which contained a query needed a reset.

Adding wp_reset_query(); after the initial query has fixed the issue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.