Created
March 5, 2013 18:12
-
-
Save mjangda/5092646 to your computer and use it in GitHub Desktop.
Add Liveblog entries to the feed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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?