Option for having the front page display a random comic (& comic blogpost for it, if applicable)

*new feature*

Signed-off-by: Philip M. Hofer (Frumph) <frumph_dragon@yahoo.com>
This commit is contained in:
Philip M. Hofer (Frumph) 2010-01-10 15:13:35 -08:00
parent d696edd7ef
commit 202e0d51ff
5 changed files with 27 additions and 7 deletions

View File

@ -79,7 +79,8 @@ function comicpress_admin() {
'disable_comic_frontpage',
'disable_comic_blog_frontpage',
'disable_comic_blog_single',
'disable_blog_frontpage'
'disable_blog_frontpage',
'enable_random_comic_frontpage'
) as $key) {
$comicpress_options[$key] = (bool)( $_REQUEST[$key] == 1 ? true : false );
}

View File

@ -144,6 +144,7 @@ function comicpress_load_options() {
'cp_theme_layout' => 'standard',
'transcript_in_posts' => false,
'enable_widgetarea_use_sidebar_css' => false,
'enable_random_comic_frontpage' => false,
'enable_custom_image_header' => false,
'custom_image_header_width' => '980',

View File

@ -3,13 +3,16 @@
<?php if (!$comicpress_options['disable_comic_frontpage'] && !$comicpress_options['disable_comic_blog_frontpage'] && !is_paged() ) {
Protect();
$comic_query = '&showposts=1&cat='.get_all_comic_categories_as_cat_string();
$posts = query_posts($comic_query);
global $frontpage_postnum;
if (isset($frontpage_postnum)) {
$post = & get_post( $frontpage_postnum );
} else {
$comic_query = '&showposts=1&cat='.get_all_comic_categories_as_cat_string();
$posts = query_posts($comic_query);
}
$wp_query->is_archive = false;
if (have_posts()) {
while (have_posts()) : the_post();
comicpress_display_post();
endwhile;
comicpress_display_post();
}
Restore();
UnProtect();

View File

@ -22,10 +22,16 @@
<?php
if (!$comicpress_options['disable_comic_frontpage'] && is_home()) {
Protect();
$comic_query = 'showposts=1&cat='.get_all_comic_categories_as_cat_string();
if ($comicpress_options['enable_random_comic_frontpage'] && is_home()) {
$comic_query = 'showposts=1&orderby=rand&cat='.get_all_comic_categories_as_cat_string();
} else {
$comic_query = 'showposts=1&cat='.get_all_comic_categories_as_cat_string();
}
$posts = query_posts($comic_query);
if (have_posts()) {
while (have_posts()) : the_post();
global $frontpage_postnum;
$frontpage_postnum = $post->ID;
$wp_query->is_single = true;
comicpress_display_comic_area();
endwhile;

View File

@ -64,6 +64,15 @@
<?php _e('Checkmark this and the blog portion of the comic will not display on the single/archive pages of your site.','comicpress'); ?>
</td>
</tr>
<tr>
<th scope="row"><label for="enable_random_comic_frontpage"><?php _e('Have it so that the index/front page shows a random comic each pageload?','comicpress'); ?></label></th>
<td>
<input id="enable_random_comic_frontpage" name="enable_random_comic_frontpage" type="checkbox" value="1" <?php checked(true, $comicpress_options['enable_random_comic_frontpage']); ?> />
</td>
<td>
<?php _e('When this is checkmarked, the front page will display a random comic from the archive.','comicpress'); ?>
</td>
</tr>
</table>
</div>