Skip to content

Instantly share code, notes, and snippets.

@norcross
Created September 6, 2012 19:42
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 norcross/3659837 to your computer and use it in GitHub Desktop.
Save norcross/3659837 to your computer and use it in GitHub Desktop.
listing closed liveblog
add_shortcode( 'liveblog_recap', 'wpcom_liveblog_recap' );
function wpcom_liveblog_recap( $atts, $content = null) {
// get ID if shortcode has declared
extract(shortcode_atts(array(
'id' => ''
), $atts));
// bail if missing ID
if (empty($id))
return $content;
global $wpdb;
$liveblog_id = $id;
$liveblog_key = 'liveblog';
$liveblog_query = $wpdb->prepare("
SELECT comments.comment_ID
FROM $wpdb->comments AS comments
WHERE comments.comment_post_ID = ".$liveblog_id."
AND comments.comment_type = '".$liveblog_key."'
AND comments.comment_approved = '".$liveblog_key."'
");
$liveblog = $wpdb->get_col($liveblog_query);
$content = '<div class="liveblog_recap">';
foreach ($liveblog as $entry) {
$liveblog_data = get_comment( $entry );
$content .= '<div class="recap_entry">';
$content .= '<p>'.$liveblog_data->comment_content.'</p>';
$content .= '</div>';
}
$content .= '</div>';
return $content;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment