PHP Conditionals: How to Get Something To Show Up on Only One Page

Discussion in 'PHP' started by airraid81, Apr 5, 2008.

  1. #1
    Wondering how to use conditionals in php/wordpress to get something to appear on only one page of the site?
     
    airraid81, Apr 5, 2008 IP
  2. kmap

    kmap Well-Known Member

    Messages:
    2,215
    Likes Received:
    29
    Best Answers:
    2
    Trophy Points:
    135
    #2
    detect the url of page

    If that matches with the url u want to place text

    then print otherwise not

    if (strcmp(substr($_SERVER["SCRIPT_NAME"],strrpos($_SERVER["SCRIPT_NAME"],"/")+1),"page u want.php")
    {
    echo "text";

    }
     
    kmap, Apr 5, 2008 IP
  3. fsmedia

    fsmedia Prominent Member

    Messages:
    5,163
    Likes Received:
    262
    Best Answers:
    0
    Trophy Points:
    390
    #3
    since it's wordpress, it's FAR easier than that.

    Take a look here, http://codex.wordpress.org/Conditional_Tags -- then you will want to look at the is_page() tag.

    Basiclally you'll want to do something like this:

    <?php if ( is_page('##') ) { ... } ?>
     
    fsmedia, Apr 5, 2008 IP