How do I do this

Discussion in 'PHP' started by bscdesign.com, Aug 20, 2007.

  1. #1
    I am trying to set up my template in wordpress but I need to make it so that the posts HTML code isn't entered the same as on the home page on the permalink page. I am trying to say only show this HTML code if the URL isn't for a permalink page. Here is a sample URL: http://mysite.com/2007/08/20/post-name/

    Here is the code I am using:
    <?php if (!preg_match("#^(/[.*]+/[.*]+/[.*]+/[.*]+/)$#", $_SERVER['REQUEST_URI'])) : ?>
    
    // HTML code here
    
    <?php endif; ?>
    PHP:
    Please help.
     
    bscdesign.com, Aug 20, 2007 IP
  2. nhl4000

    nhl4000 Well-Known Member

    Messages:
    479
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    110
    #2
    <?php
    $_URL = $_SERVER['REQUEST_URI'];
    if (substr($_URL,(strlen($_URL)-1),1)!="/")
    echo "Not Permalink!";
    // HTML code here
    ?>
    PHP:
    I don't know PHP so bare with me. I'm trying my best. :)
     
    nhl4000, Aug 20, 2007 IP
  3. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #3
    
    if (!preg_match('/20\d{2}\/[01][0-9]\/[0-3][0-9]\//', $_SERVER['REQUEST_URI']))
    
    PHP:
    This should do it.
     
    nico_swd, Aug 21, 2007 IP
  4. bscdesign.com

    bscdesign.com Active Member

    Messages:
    681
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    58
    #4
    Thanks a ton nico. It works perfectly.
     
    bscdesign.com, Aug 21, 2007 IP