• Hi.
    I have had success using conditional statements in previous websites, but I seem to be stuck.

    I have an item in my footer that I would like to only show on the home page. Traditionally, I would use such a code to accomplish this:

    <?php if (is_home()) { ?>
    **the item I want to show***
    <?php } ?>

    In troubleshooting this, I have determined that no conditional statements will work on my website if placed in the footer section. Additionally, I have discovered that while conditional statements will work if placed in my sidebar, they won’t work if I use “is_home” or “is_front_page”. I don’t get an error, just nothing shows up.

    Using statements such as “is_category” work just fine if in my sidebar, but not in my footer.

    That is probably two different issues, but in either case I’m stumped by the occurance.

    What could be preventing such code from working?

    Thanks in advance for any help.
    ~Christian

Viewing 3 replies - 1 through 3 (of 3 total)
  • Must be something such as a plugin or your theme disrupting those values. If I put your code in the WordPress Default themes wp-content/themes/default/footer.php it works fine.

    Might try switching themes to the WordPress Default theme and make the change to the footer there. If that doesn’t work, then deactivate all plugins and using the WordPress Default theme try again.

    Thread Starter cphine

    (@cphine)

    Thanks for the response.

    Indeed, changing to the default theme, but keeping all plugins active, allows the code to work.

    Furthermore, in a cleaner installation of the theme on another server, the same problems arise. ie. Placing conditionals in the footer do not work regardless of the type. Placing them in the sidebar work, so long as they do not reference (is_home). I did realize that by using (is_category) in the sidebar that the desired occurance would take place both in category archives and on the home page. It’s thinking the home page is a category archive.

    I’m guessing we have determined that it is the theme code causing the issue. Any ideas what, on a theme level, could be disrupting the code from working?

    Thanks in advance for any assistance.

    I was having the same exact issue and found this simple solution:

    add this above your conditional statement in your footer:

    ‘<?php wp_reset_query(); ?>’

    Solution found here:
    https://weblogtoolscollection.com/archives/2010/01/16/fix-for-is_home-is_archive-not-working/

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Conditional tags not working’ is closed to new replies.