need most commented, but with c2c_get_custom
-
I use c2c’s get_custom function to retrieve little thumbnails for each post, which I put in a “thumb” custom field.
I’d really like to be able to show a list of Most Commented (or Recently Commented) but with the ability to use the values from custom fields – but most plugins just give you a link.
I presume this is going to require a little hacking of the most commented script – but it’s not like I can just slot an extra bit into the script like this, is it? Guess I should just try, but I’m afraid of breaking stuff:
function mdv_most_commented($no_posts = 5, $before = '<li>', $after = '</li>', $show_pass_post = false) {
global $wpdb;
$request = "SELECT ID, post_title, COUNT($wpdb->comments.comment_post_ID) AS 'comment_count' FROM $wpdb->posts, $wpdb->comments";
$request .= " WHERE comment_approved = '1' AND $wpdb->posts.ID=$wpdb->comments.comment_post_ID AND post_status = 'publish'";
if(!$show_pass_post) $request .= " AND post_password =''";
$request .= " GROUP BY $wpdb->comments.comment_post_ID ORDER BY comment_count DESC LIMIT $no_posts";
$posts = $wpdb->get_results($request);
$output = '';
if ($posts) {
foreach ($posts as $post) {
$post_title = stripslashes($post->post_title);
$comment_count = $post->comment_count;
$permalink = get_permalink($post->ID);//new line here!!
$MYCUSTOMVALUE = c2c_get_custom('thumb');
$output .= $before . '<a href="' . $permalink . '" title="' . $post_title.'">' . $MYCUSTOMVALUE . '</a> (' . $comment_count.')' . $after;
}
} else {
$output .= $before . "None found" . $after;
}
echo $output;
}that wouldn’t work, right..?
or would it?
Or would I have to at least do a require_once and call the c2c script beforehand??
please help!
- The topic ‘need most commented, but with c2c_get_custom’ is closed to new replies.