Skip to content

Instantly share code, notes, and snippets.

@mjangda
Created March 5, 2013 18:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mjangda/5092646 to your computer and use it in GitHub Desktop.
Save mjangda/5092646 to your computer and use it in GitHub Desktop.
Add Liveblog entries to the feed
<?php
/**
* Output Liveblog entries as part of feed content
**/
if ( class_exists( 'WPCOM_Liveblog' ) )
add_filter( 'the_content_feed', 'x_add_liveblog_entries_to_feed_content' );
function x_add_liveblog_entries_to_feed_content( $content ) {
if ( WPCOM_Liveblog::is_liveblog_post() ) {
$post_id = get_the_ID();
$liveblog_query = new WPCOM_Liveblog_Entry_Query( $post_id, WPCOM_Liveblog::key );
$liveblog_entries = $liveblog_query->get_all();
$content .= PHP_EOL;
$content .= '<h2 class="from-liveblog">From the Liveblog</h2>';
foreach ( $liveblog_entries as $liveblog_entry ) {
$entry_info = $liveblog_entry->get_fields_for_render();
$content .= '<h5 class="from-liveblog-time">' . $entry_info['entry_time'] . '</h5>' . $entry_info['content'];
}
}
return $content;
}
@nitinthewiz
Copy link

I wonder if this can be used to create a feed for the liveblog itself, so that can be pushed to social networks and tumblr?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment