diff --git a/classes/ComicPress.inc b/classes/ComicPress.inc index 4672e65..a04ebef 100644 --- a/classes/ComicPress.inc +++ b/classes/ComicPress.inc @@ -171,6 +171,23 @@ class ComicPress { } return false; } + + /** + * Find the terminal post in a specific category. + */ + function get_terminal_post_in_category($category_id, $first = true) { + $sort_order = $first ? "asc" : "desc"; + $terminal_comic_query =$this->_new_wp_query(); + $terminal_comic_query->query("showposts=1&order=${sort_order}&cat=${category_id}"); + if ($terminal_comic_query->have_posts()) { + return reset($terminal_comic_query->posts); + } + return false; + } + + function _new_wp_query() { + return new WP_Query(); + } } ?> \ No newline at end of file diff --git a/functions.php b/functions.php index c2592a8..e3fd129 100644 --- a/functions.php +++ b/functions.php @@ -162,24 +162,6 @@ function get_adjacent_comic($category, $next = false) { return get_adjacent_post(false, $categories_to_exclude, $next); } -/** - * Find the terminal post in a specific category. - */ -function get_terminal_post_in_category($categoryID, $first = true) { - global $post; - - $temp = $wp_query; $wp_query = null; - $sortOrder = $first ? "asc" : "desc"; - $terminalComicQuery = new WP_Query(); $terminalComicQuery->query("showposts=1&order=${sortOrder}&cat=${categoryID}"); - $terninalPost = false; - if ($terminalComicQuery->have_posts()) { - $terminalPost = reset($terminalComicQuery->posts); - } - - $wp_query = null; $wp_query = $temp; - return $terminalPost; -} - /** * Find a comic file in the filesystem. * @param string $folder The folder name to search.