WordPress.org

Ready to get started?Download WordPress

Forums

How to test for static homepage inside a plugin (2 posts)

  1. frontdesk
    Member
    Posted 1 year ago #

    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?

  2. esmi
    Forum Moderator
    Posted 1 year ago #

Topic Closed

This topic has been closed to new replies.

About this Topic