0'; } if ($cat_id) { $query = "select distinct posts.ID from $wpdb->posts posts left join $wpdb->term_relationships term_relationships on (posts.ID=term_relationships.object_id) left join $wpdb->term_taxonomy term_taxonomy on (term_relationships.term_taxonomy_id=term_taxonomy.term_taxonomy_id) where posts.post_type='post' and (term_taxonomy.term_id=$cat_id or term_taxonomy.parent=$cat_id) and term_taxonomy.taxonomy='category'"; $records = $wpdb->get_results($query); if ($wpdb->last_error) { echo 'error: '.$wpdb->last_error; return; } $posts = array(); foreach ($records as $record) { $posts[] = $record->ID; } $where2 = implode($posts, ','); if ($where2) { $where2 = ' and posts.ID in ('.$where2.') '; } } $query = "select count(posts.ID) from $wpdb->posts posts left join $thanksCountersTable counters on counters.post_id=posts.ID where 1=1 $where1 $where2 and posts.post_type='post'"; $thankedPosts = $wpdb->get_var($query); if ($wpdb->last_error) { echo 'error: '.$wpdb->last_error; return; } $maxNumPages = (int) ($thankedPosts / $rowsPerStatPage); $rest = $thankedPosts / $rowsPerStatPage - $maxNumPages; if ($rest>0) { $maxNumPages += 1; } if ($_GET['paged']>$maxNumPages) { $_GET['paged'] = $maxNumPages; } $fromRecord = max(0,($_GET['paged'] - 1))*$rowsPerStatPage; $query = "select posts.ID, posts.post_title, counters.quant, counters.updated from $wpdb->posts posts left join $thanksCountersTable counters on counters.post_id=posts.ID where 1=1 $where1 $where2 and posts.post_type='post' order by $sortField $sortDir limit $fromRecord, $rowsPerStatPage"; $records = $wpdb->get_results($query); if ($wpdb->last_error) { echo 'error: '.$wpdb->last_error; return; } $foundPosts = count($records); ?>
add_query_arg('paged', '%#%', $base), 'format' => '', 'prev_text' => '«', 'next_text' => '»', 'total' => $maxNumPages, 'current' => $_GET['paged'] )); ?>
posts WHERE post_type = 'post' ORDER BY post_date DESC"; $arc_result = $wpdb->get_results( $arc_query ); $month_count = count($arc_result); if ($month_count && !(1 == $month_count && 0 == $arc_result[0]->mmonth)) { ?> __('View all categories','thankyou'), 'hide_empty' => 1, 'hierarchical' => 1, 'show_count' => 1, 'orderby' => 'name', 'selected' => $cat_id); wp_dropdown_categories($dropdown_options); if (isset($_GET['zeroshow'])) { $checked = 'checked="checked"'; } else { $checked = ''; } ?>  />        
' . __( 'Displaying %s–%s of %s','thankyou' ) . '%s', number_format_i18n(max($_GET['paged'] - 1, 0)*$rowsPerStatPage + 1), number_format_i18n(min( $_GET['paged']*$rowsPerStatPage, $thankedPosts)), number_format_i18n($thankedPosts), $page_links ); echo $page_links_text; ?>
'; } else { $newSortDir = 'asc'; $newSortDirTitle = __('ascending', 'thankyou'); $currentSortDirTitle = __('Descending order', 'thankyou'); $currentSortDirImg = ''.$currentSortDirTitle.''; } $quantSortDirImg = $currentSortDirImg; $updatedSortDirImg = ''; $linkQuant = add_query_arg('sortdir', $newSortDir, $link); } else { if ($sortDir=='asc') { $newSortDir = 'desc'; $newSortDirTitle = __('descending', 'thankyou'); $currentSortDirTitle = __('Ascending order', 'thankyou'); $currentSortDirImg = ''.$currentSortDirTitle.''; } else { $newSortDir = 'asc'; $newSortDirTitle = __('ascending', 'thankyou'); $currentSortDirTitle = __('Descending order', 'thankyou'); $currentSortDirImg = ''.$currentSortDirTitle.''; } $linkUpdated = add_query_arg('sortdir', $newSortDir, $link); $quantSortDirImg = ''; $updatedSortDirImg = $currentSortDirImg; } $newSortDirTitle = sprintf(__('Click to sort in %s order','thankyou'), $newSortDirTitle); $linkQuant = add_query_arg('sortfield', 'quant', $linkQuant); $linkUpdated = add_query_arg('sortfield', 'updated', $linkUpdated); function thShow($linkQuant, $linkUpdated, $newSortDirTitle, $newSortDirTitle, $quantSortDirImg, $updatedSortDirImg) { ?> updated, true); ?>
ID; ?> post_title; ?> quant) ? $record->quant : 0; ?>
' . __('Displaying %s–%s of %s','thankyou') . '%s', number_format_i18n( ( $_GET['paged'] - 1 ) * $rowsPerStatPage + 1 ), number_format_i18n( min( $_GET['paged'] * $rowsPerStatPage, $thankedPosts ) ), number_format_i18n( $thankedPosts ), $page_links ); echo $page_links_text; ?>