prepare( "SELECT p.`ID`, p.`post_title`, p.`post_content`, p.`post_date`, mcw.`meta_value` as possible_winners, p.`comment_count` FROM `{$wpdb->posts}` p INNER JOIN `{$wpdb->postmeta}` mic ON mic.`meta_key` = %s AND mic.`post_ID` = p.`ID` INNER JOIN `{$wpdb->postmeta}` mcw ON mcw.`meta_key` = %s AND mcw.`post_ID` = p.`ID` WHERE p.`comment_count` > 0 ", ATWI_POST_META_IS_CONTEST, ATWI_POST_META_NUMBER_OF_WINNERS ); if ( !empty( $search ) ) { $query = $wpdb->prepare( $query . "AND p.`post_title` LIKE %s ", "%$search%" ); $search_link = $link . "&s=$search"; } $query .= "ORDER BY p.`post_date` DESC;"; $posts = $wpdb->get_results( $query ); $posts_per_page = 3; $total = count( $posts ); $total_pages = intval( ceil( $total / $posts_per_page ) ); $page = ( isset( $_GET[ "paged" ] ) ) ? intval( $_GET[ "paged" ] ) : 1; $paged = ( isset( $_GET[ "paged" ] ) ) ? "&paged=" . $_GET[ "paged" ] : ""; $start = ( ( $page - 1 ) * $posts_per_page ) + 1; $end = $start + $posts_per_page - 1; if ( $end > $total ) { $end = $total; } ?>

 “" class="button">

$posts_per_page ) : ?>
1 ) { if ( 1 !== $page ) { $prev = $page - 1; // show the previous page link echo "«"; } // show up to 5 pages in the middle if ( $total_pages < 5 ) { $to_show = $total_pages; $start_page = 1; } else { $start_page = ( ( $page - 2 ) < 1) ? 1 : $page - 2; $to_show = 5; if ( ( $start_page + $to_show ) > $total_pages ) { $start_page = $total_pages - 4; } } if ( $start_page > 1 ) { echo "1"; if ( $start_page > 2 ) { echo "…"; } } for ( $i = $start_page; $i < ( $start_page + $to_show ); $i++ ) { // show page links if ( $i === $page ) { echo "$i"; } else { echo "$i"; } } if ( $total_pages >= ( $start_page + $to_show ) ) { if ( $total_pages > ( $start_page + $to_show ) ) { echo "…"; } echo "{$total_pages}"; } if ( $page !== $total_pages ) { // show the next page link $next = $page + 1; echo "»"; } } ?>
0 ) : for ( $index = ( $start - 1 ); $index < $end; $index++ ) { $post = $posts[ $index ]; $contest = new AndTheWinnerIs_Contest( $post->ID ); if ( $contest->GetNumberOfEntries() > 0 ) : $count++; $winners = $contest->GetAllWinners(); $date = new DateTime( $post->post_date ); ?>
post_title, null, null, $post->ID ); ?>
format( "m/d/Y" ); ?>

post_content ), 0, 400 ); ?>…

GetNumberOfWinnersPossible(); $i++) { ?>
GetCommentBlock(); } ?>
GetNumberOfEntries(); ?> GetNumberOfWinnersPossible(); ?>