Add hashtag automatically to live blog tweet (2 posts)

Topic tags: live blogging plugin
  • Profile picture of Andy Christian Andy Christian said 1 year, 7 months ago:

    Hi. I’ve been live blogging WordCamp Philly using the Live Blogging plugin from Chris Northwood (who is no longer actively developing it). I want to add to the following code the ability to pull a custom field entitled “hashtag” from the original post and append it to the end of the tweet.

    Does anybody know how I would go about this? I searched on the codex and tried to add the code based on what I found there, but it returned errors.

        add_action('publish_liveblog_entry', 'live_blogging_tweet', 10, 2);
        function live_blogging_tweet($id, $post)
        {
            if ('1' == get_option('liveblogging_enable_twitter') && '' == get_post_meta($id, '_liveblogging_tweeted', true))
            {
                $connection = new TwitterOAuth(LIVE_BLOGGING_TWITTER_CONSUMER_KEY, LIVE_BLOGGING_TWITTER_CONSUMER_SECRET, get_option('liveblogging_twitter_token'), get_option('liveblogging_twitter_secret'));
                $content = filter_var($post->post_content, FILTER_SANITIZE_STRING);
                if (strlen($content) > 140)
                {
                    $tweet = $connection->post('statuses/update', array('status' => substr($content, 0, 139) . html_entity_decode('…', ENT_COMPAT, 'UTF-8')));
                }
                else
                {
                    $tweet = $connection->post('statuses/update', array('status' => $content));
                }
            }
            if (isset($tweet->id))
            {
                update_post_meta($id, '_liveblogging_tweeted', $tweet->id);
            }
        }
    
  • Profile picture of Kevin Cristiano Kevin Cristiano said 1 year, 7 months ago:

    Take a look at these as examples:

    http://plugins.svn.wordpress.org/twitter-tools/tags/2.4/twitter-tools.php

    http://plugins.svn.wordpress.org/wp-to-twitter/tags/2.3.3/wp-to-twitter.php

    Search for “hashtag” in the code.

    This can then show you how they do it. Then you can see if you can incorporate their logic into the changes you want in the liveblogging plugin.