Created
September 6, 2012 19:42
-
-
Save norcross/3659837 to your computer and use it in GitHub Desktop.
listing closed liveblog
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
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