public static function archive($post_type) { wb_set('current_url', get_post_type_archive_link($post_type)); query_posts(array('post_type' => $post_type)); if (!($template = get_archive_template())) { $template = WB_PATH . '/archive.php'; } wb_link_hack(true); include $template; wb_link_hack(false); wp_reset_query(); }
/** * Displays pagination * * @param integer $pages * @param integer $range */ function wb_pagination($pages = null, $range = 2) { global $paged, $wp_query; $output = ''; $showitems = $range * 2 + 1; if (!$paged) { $paged = 1; } if (!$pages) { if (!($pages = $wp_query->max_num_pages)) { $pages = 1; } } if ($pages > 1) { wb_link_hack(true); $output .= '<ul class="pagination">'; // First page if ($paged > 2 && $paged > $range + 1 && $showitems < $pages) { $output .= '<li><a href="' . get_pagenum_link(1) . '">«</a></li>'; } // Previous page if ($paged > 1 && $showitems < $pages) { $output .= '<li><a href="' . get_pagenum_link($paged - 1) . '">‹</a></li>'; } // Page numbers for ($i = 1; $i <= $pages; $i++) { if (1 != $pages && (!($i >= $paged + $range + 1 || $i <= $paged - $range - 1) || $pages <= $showitems)) { if ($paged == $i) { $output .= '<li class="active"><span class="current">' . $i . '</span></li>'; } else { $output .= '<li><a href="' . get_pagenum_link($i) . '" class="inactive" >' . $i . '</a></li>'; } } } // Next page if ($paged < $pages && $showitems < $pages) { $output .= '<li><a href="' . get_pagenum_link($paged + 1) . '">›</a></li>'; } // Last page if ($paged < $pages - 1 && $paged + $range - 1 < $pages && $showitems < $pages) { $output .= '<li><a href="' . get_pagenum_link($pages) . '">»</a></li>'; } $output .= '</ul>'; wb_link_hack(false); } echo $output; }