WordPress.org

Ready to get started?Download WordPress

Forums

Page-specific variable? (6 posts)

  1. pcmt
    Member
    Posted 8 years ago #

    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.

  2. masquerade
    Member
    Posted 8 years ago #

    if(is_page())

  3. pcmt
    Member
    Posted 8 years ago #

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

  4. masquerade
    Member
    Posted 8 years ago #

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

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

  5. pcmt
    Member
    Posted 8 years ago #

    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?

  6. pcmt
    Member
    Posted 8 years ago #

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

    if (is_page('my-page-slug')) {

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags