Support » Everything else WordPress » Check if main page – outside index.php

  • Okay – I know I can check if it is the main page with
    <?php if (is_home()) { echo "ohai"; }?>
    But it only works on index.php or main page of the template, it’s no good elsewhere.
    I’d need that in other template files (footer.php to be exact).

    $_SERVER['PHP_SELF'] came to my mind, but it’s no good with WordPress since current script is always index.php.

    Any other solutions? :/

Viewing 2 replies - 1 through 2 (of 2 total)
  • $_SERVER[‘REQUEST_URI’] may help you.

    I also know that is_home() or is_index() (I can’t remember if that one is real though…) work in the functions.php file.

    Specifically what file are you trying to add that decision to? Then we may be of more help to you.

    – Terri

    I’ll try with request uri tomorrow, ty.
    is_index() doesn’t exist, is_home() doesn’t work, as I said above… :/

    Hokay, here’s more info:
    My site is here:
    I’m using a free theme / template, so I’m still not that familiar with ins and outs of the template (and WP for that matter). The main template file seems to be home.php, I’m trying to put that decision into footer.php.

    I can’t put it directly into home.php becase of the way theme is coded – what I want to do is put <div>…</div> above my site’s footer, full width. So footer.php is the only option I can see…

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Check if main page – outside index.php’ is closed to new replies.