WordPress.org

Support

Support » Installation » Page-specific variable?

Page-specific variable?

  • Is there a standard page-specific php variable that can be identified on each page. I would like to use this to format my navigation bar.

    Many thanks.

Viewing 5 replies - 1 through 5 (of 5 total)
  • if(is_page())

    Thanks, but what goes inside the brackets? What is the actual page-specific variable? Or is it a string?

    That’s what you can use to tell if its a page or not, for example

    <?php
    if(is_page()) {
    //anything here is executed
    }

    Yes, but what I want to do is to know which page it is, so that I can format my navbar accordingly. For example “if (is_home())” identifies that it is the homepage, but I’m not sure how. I’m looking for something like “if (is_somepage())” – so what sets “somepage” for each of my pages?

    Actually, it seems to work by using the page slug:

    if (is_page(‘my-page-slug’)) {

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Page-specific variable?’ is closed to new replies.
Skip to toolbar