From 2924eaf1ad5b791c5ed77021da90c809c5fc6e71 Mon Sep 17 00:00:00 2001 From: John Bintz Date: Sun, 19 Jul 2009 19:20:23 -0400 Subject: [PATCH] move index blog posts out of index.php --- classes/ComicPress.inc | 28 ++++++++++++++++++++++++++++ index.php | 17 ++--------------- 2 files changed, 30 insertions(+), 15 deletions(-) diff --git a/classes/ComicPress.inc b/classes/ComicPress.inc index 3b44772..7af093f 100644 --- a/classes/ComicPress.inc +++ b/classes/ComicPress.inc @@ -326,6 +326,34 @@ class ComicPress { } return false; } + + /** + * Gather blog posts for the given index page. + */ + function get_index_blog_posts() { + global $post, $paged; + + $t = $post; + + $wp_query = new WP_Query(); + $wp_query->query( + 'showposts=' . + (int)$this->comicpress_options['blogpost_count'] . + '&cat=-' . + $this->comicpress_options['comic_category_id'] . + '&paged=' . + $paged + ); + + $posts = array(); + if ($wp_query->have_posts()) { + while ($wp_query->have_posts()) { $wp_query->the_post(); $posts[] = $post; } + } + + $post = $t; + + return $posts; + } } ?> \ No newline at end of file diff --git a/index.php b/index.php index d496c24..535ac85 100644 --- a/index.php +++ b/index.php @@ -1,7 +1,7 @@ get_nav_comics(); $post = $nav_comics['last']; @@ -15,22 +15,9 @@ query( - 'showposts=' . - (int)$comicpress->comicpress_options['blogpost_count'] . - '&cat=-' . - $comicpress->comicpress_options['comic_category_id'] . - '&paged=' . - $paged - ); - - while ($wp_query->have_posts()) { - $wp_query->the_post(); + foreach ($comicpress->get_index_blog_posts() as $post) { include_partial('index-blog-post'); } - - include_partial('index-blog-post'); ?>