Get current post's URL ?

Discussion in 'PHP' started by crystak, Mar 29, 2008.

  1. #1
    I want to add a text box to the end of my post where the HTML needed to link back to my post is displayed and people would only need it to copy and paste it. I am thinking of using the below code, would this work, because I copied it from somewhere?

    Also, how can I get the URL of the current post so I wouldn't have to edit it each time?

    <div align="center"><strong><font color="#FF5EAA">Link to this Story</font></strong><center><br />
    
    <form method="POST" action="#" wrap="virtual">
    <textarea rows="4" name="link" cols="50"><a href="URL OF CURRENT POST"><?php the_title(); ?></a></textarea>
    </form>
    </div>
    PHP:
     
    crystak, Mar 29, 2008 IP
  2. jestep

    jestep Prominent Member

    Messages:
    3,659
    Likes Received:
    215
    Best Answers:
    19
    Trophy Points:
    330
    #2
    Try:

    
    
    <div align="center"><strong><font color="#FF5EAA">Link to this Story</font></strong><center><br />
    
    <textarea rows="4" name="link" cols="50">
    <a href="<?php echo 'http://'.$_SERVER["HTTP_HOST"].$_SERVER["PHP_SELF"]; ?>"><?php the_title(); ?></a>
    </textarea>
    
    </div>
    
    
    PHP:
    You don't need or want the form tag, just use the textarea.
     
    jestep, Mar 29, 2008 IP
  3. Breakaway11

    Breakaway11 Well-Known Member

    Messages:
    882
    Likes Received:
    27
    Best Answers:
    0
    Trophy Points:
    120
    #3
    Have you tried searching for a plugin for this type of thing...
     
    Breakaway11, Mar 29, 2008 IP