WordPress.org

Ready to get started?Download WordPress

Forums

Live Blogging
[resolved] Automatically add a link to tweets? (10 posts)

  1. Jeremy Sarber
    Member
    Posted 2 years ago #

    I've love if all tweets from the live blog went out with a link back to the post. Is this possible with custom fields?

    http://wordpress.org/extend/plugins/live-blogging/

  2. Jeremy Sarber
    Member
    Posted 2 years ago #

    I assume I could change this to make it work...

    //add hashtag
                if ($hashtag)
    	    {
                    $content .= " #" . $hashtag;
    	    }
  3. Jeremy Sarber
    Member
    Posted 2 years ago #

    Nevermind. I just deleted the # and it was good to go. Of course, if I ever need to use a hashtag, I'll just be sure to include the # in the custom field.

  4. cianmm
    Member
    Posted 2 years ago #

    Is there any chance you could elaborate on what you did to make links show up in tweets?

    Thanks,
    Cian

  5. Jeremy Sarber
    Member
    Posted 2 years ago #

    Go to Plugins --> Editor --> Live Blogging --> live-blogging.php

    Find this:

    //add hashtag
                if ($hashtag)
    	    {
                    $content .= " #" . $hashtag;
    	    }

    Change it to:

    //add hashtag
                if ($hashtag)
    	    {
                    $content .= " " . $hashtag;
    	    }

    Then, when you create the live blog post, add a custom field with the name "liveblogging_hashtag" followed by the link you want under Value. I'd get the link shortened before you insert it and save.

  6. cianmm
    Member
    Posted 2 years ago #

    Many thanks!
    I appreciate your coming back a month later to help me and future people who search out.

    Cian

  7. Jeremy Sarber
    Member
    Posted 2 years ago #

    You're welcome. I'm always happy to help the community. I know they've been there for me in the past.

  8. densey
    Member
    Posted 1 year ago #

    I made these changes to add the URL (changes in bold):

    //get the hashtag (we need the id of the parent blog post, not $post->ID here)
     $parent_post_id = (int)$_POST['live_blogging_entry_post'];
    $hashtag = get_post_meta($parent_post_id, "liveblogging_hashtag", true);
    <strong>$permalink = get_permalink( $parent_post_id );</strong>
    
     //how much space do we have?
    if ($hashtag) {
     $tweetlength = 140 - strlen($hashtag)<strong>- strlen($permalink</strong>)- 2;
    	    } else {
                    $tweetlength = 140;
    	    }
    
      //do I need to trim the tweet?
     if (strlen($content) > $tweetlength) {
     $content = substr($content, 0, $tweetlength - 1)
                             . html_entity_decode('…', ENT_COMPAT, 'UTF-8');
     }
    //add hashtag and permalink
    if ($hashtag)
       {
    $content .= " #" . $hashtag<strong>." ".$permalink</strong>;
        }

    [Moderator Note: Please post code or markup snippets between backticks or use the code button.]

  9. nickc25
    Member
    Posted 1 year ago #

    I know this is a few months old now but I am wondering if there is a way to shorten the permalinks in anyway?

    Our URL's are pretty long so take up a large portion of each tweet, it would be much better if they were output in a format such as bit.ly etc.

    If anyone knows how to do this can you let me know?

    Thanks

    Nick

  10. chrisnorthwood
    Member
    Plugin Author

    Posted 1 year ago #

    nickc25: Follow Jeremy Sarber's instructions and instead of putting a hashtag in the liveblogging_hashtag custom field putting a short URL instead should sort it

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic