Forums

[resolved] Parse the_title() as a URL (3 posts)

  1. designinfantry
    Member
    Posted 2 years ago #

    <?php
    global $id;
    $mytitle = the_title();
    echo '<a href="http://twitter.com/home?status=' . $mytitle . get_bloginfo('url') .
    '/?p=' . $id . '%20RT%20@nullweknow' . '" title="Tweet">Tweet</a>';
    ?>

    I want to retweet the title, but the above var doesn't parse the_title() as a url. Can someone help?

  2. alchymyth
    The Sweeper
    Posted 2 years ago #

    the_title needs to be used in the loop

    try
    http://codex.wordpress.org/Template_Tags/get_the_title

    which returns a string and takes the ID which you seem to have as a global variable.

  3. designinfantry
    Member
    Posted 2 years ago #

    <?php
    global $id;
    echo $title;
    echo '<a href="http://twitter.com/home?status=' . get_the_title($id) . '%20' . get_bloginfo('url') .
    '/?p=' . $id . '%20RT%20@nullweknow' . '" title="Tweet" target="_blank">Tweet</a>';
    ?>

    Amazing. Works like a charm.

Topic Closed

This topic has been closed to new replies.

About this Topic