get_results("SELECT * FROM $tablecomments WHERE comment_post_ID = $post->ID AND comment_type NOT LIKE 'trackback' AND comment_type NOT LIKE 'pingback' AND comment_approved = '1'"); $count = count($comments); if($count > 1) { echo str_replace('%', number_format_i18n($count), ( false === $more ) ? __('% Comments') : $more); } else if($count == 1) { echo $one; } else { echo $zero; } } function trackbacks_count($zero = 'No Trackback/Pingback', $one = '1 Trackback/Pingback', $more = '% Trackbacks/Pingbacks') { global $wpdb, $tablecomments, $post; $trackbacks = $wpdb->get_results("SELECT * FROM $tablecomments WHERE comment_post_ID = $post->ID AND (comment_type='trackback' OR comment_type='pingback') AND comment_approved = '1'"); $count = count($trackbacks); if($count > 1) { echo str_replace('%', number_format_i18n($count), ( false === $more ) ? __('% Comments') : $more); } else if($count == 1) { echo $one; } else { echo $zero; } } function get_first_image_resized($id, $width, $height) { global $wpdb; $image = ''; $first_image = $wpdb->get_results( "SELECT guid FROM $wpdb->posts WHERE post_parent = '$id' " ."AND post_type = 'attachment' AND post_mime_type LIKE 'image%' ORDER BY 'post_date' ASC LIMIT 0,1" ); if($first_image) { $image = $first_image[0]->guid; return get_bloginfo('template_url') . "/library/timthumb.php?src=$image&w=$width&h=$height&zc=1"; } else { return null; } } function get_resized_image($image, $width, $height) { return get_bloginfo('template_url') . "/library/timthumb.php?src=$image&w=$width&h=$height&zc=1"; } function get_thumbnail($id, $width, $height) { $thumbnail = get_post_meta($id, 'thumbnail', true); if($thumbnail) { return get_resized_image($thumbnail, $width, $height); } else{ return get_first_image_resized($id, $width, $height); } } ?>