WordPress.org

Support

Support » Plugins and Hacks » Hacks » How to test for static homepage inside a plugin

How to test for static homepage inside a plugin

  • frontdesk

    @frontdesk

    My WP site is configured to have a static page (id=123) as my front page. It also uses the advanced menu feature that came along with WP 3.0.

    On this WP site I am using a popup plugin that currently appears on every page. I want to limit the popup to appear only the homepage, so at the beginning of the popup plugin’s code I inserted the following code:

    if (is_front_page() || (is_home() || (is_page(123)) {
       ...
       existing popup plugin code
       ...
    }

    … but now I never see the popup on any page. Note that based on some forum suggestions I also tried preceding my IF with

    wp_reset_query();

    … but that made no difference.

    I know I am in the proper area to insert this test because if I change my code to test for a truism:

    if (1 == 1) {
       ...
       existing popup plugin code
       ...
    }

    … then my popup continues to appear on every page.

    I can only guess that “is_front_page()” and “is_home()” and “is_page()” do not react as expected when inside a plugin, so how do I determine if I am on the homepage (that happens to be a static page) when inside a plugin?

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘How to test for static homepage inside a plugin’ is closed to new replies.
Skip to toolbar