Viewing 9 replies - 1 through 9 (of 9 total)
  • Thread Starter Jeremy Sarber

    (@jsarber)

    I assume I could change this to make it work…

    //add hashtag
                if ($hashtag)
    	    {
                    $content .= " #" . $hashtag;
    	    }
    Thread Starter Jeremy Sarber

    (@jsarber)

    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.

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

    Thanks,
    Cian

    Thread Starter Jeremy Sarber

    (@jsarber)

    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.

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

    Cian

    Thread Starter Jeremy Sarber

    (@jsarber)

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

    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.]

    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

    Plugin Author chrisnorthwood

    (@chrisnorthwood)

    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

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘[Plugin: Live Blogging] Automatically add a link to tweets?’ is closed to new replies.