我正在为我的教会网站建立一个自定义档案页面。在我的档案页上,我想把上周的布道放在一个特殊的盒子里,然后是未来的布道,最后是布道档案。
我希望将来的布道和布道档案用标题隔开。。。i、 未来的布道
布道档案
布道档案。。。
我的问题是,当我用分页功能点击按钮转到旧的布道帖子时,它会在我所在的每个归档页面上显示当前和未来的布道!
如何使当前和未来的布道仅显示在第1页上,而不在单击查看旧帖子时显示?
以下是我的功能:
// Create the loop for the sermons page
function sermon_posts() {
if(is_page(\'sermons\')) {
current_sermon_archives(); ?>
<h2 class="sm-header">Future Sermons</h2>
<?php future_sermon_archives(); ?>
<h2 class="sm-header">Sermon Archives</h2>
<?php sermon_archives();
}
}
function current_sermon_archives() {
$thisSunday = date(\'d\', strtotime(\'last Sunday\'));
$thisSundayMonth = date(\'n\', strtotime(\'last Sunday\'));
$lastWeekSermon = new WP_Query(array( \'posts_per_page\' => 1,
\'post_type\' => \'sermon_post\',
\'monthnum\' => $thisSundayMonth,
\'day\' => $thisSunday) );
if ( $lastWeekSermon->have_posts() ) : while ( $lastWeekSermon->have_posts() ) : $lastWeekSermon->the_post(); ?>
<div id="sm-upcoming-archives">
<h2 class="sm-header">Last Week\'s Sermon</h2>
<div class="scripture-post">
<h2><p><?php the_title(); ?></p><span class="sm-date"> - <?php the_time(get_option(\'date_format\')); ?></span></h2>
<?php echo get_the_term_list( get_the_ID(), \'speaker\' ) ?>
<?php the_content(); ?>
<div class="sermonexcerpt">
<?php $thereisdescription = get_post_meta($post->ID, "_description", true);
if($thereisdescription){ ?>
<?php echo get_post_meta($post->ID, "_description", true); ?>
<?php }else{ ?>
<?php } ?></div>
</div>
</div>
<?php endwhile; else: ?>
<?php wp_reset_postdata(); ?>
<?php endif;
}
function future_sermon_archives() {
$current_year = date(\' Y\', strtotime(\'next Sunday\'));
$current_month = date(\'M \', strtotime(\'next Sunday\'));
$current_day = date(\'d\', strtotime(\'next Sunday\'));
$futureSermon = new WP_Query(array( \'showposts\' => \'3\',
\'post_type\' => \'sermon_post\',
\'monthnum\' => $current_month,
\'day\' => $current_day) );
if ( $futureSermon->have_posts() ) : while ( $futureSermon->have_posts() ) : $futureSermon->the_post(); ?>
<div id="sm-upcoming-archives">
<h2 class="sm-header">Last Week\'s Sermon</h2>
<div class="scripture-post">
<h2><p><?php the_title(); ?></p><span class="sm-date"> - <?php the_time(get_option(\'date_format\')); ?></span></h2>
<?php echo get_the_term_list( get_the_ID(), \'speaker\' ) ?>
<?php the_content(); ?>
<div class="sermonexcerpt">
<?php $thereisdescription = get_post_meta($post->ID, "_description", true);
if($thereisdescription){ ?>
<?php echo get_post_meta($post->ID, "_description", true); ?>
<?php }else{ ?>
<?php } ?></div>
</div>
</div>
<?php endwhile; else: ?>
<?php wp_reset_postdata(); ?>
<?php endif;
}
function sermon_archives() {
query_posts(array(\'post_type\'=>\'sermon_post\', \'paged\' => get_query_var( \'paged\' ) ) ); ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<div class="scripture-post">
<h2><p><?php the_title(); ?></p><span class="sm-date"> - <?php the_time(get_option(\'date_format\')); ?></span></h2>
<?php echo get_the_term_list( get_the_ID(), \'speaker\' ) ?>
<?php the_content(); ?>
<div class="sermonexcerpt">
<?php $thereisdescription = get_post_meta($post->ID, "_description", true);
if($thereisdescription){ ?>
<?php echo get_post_meta($post->ID, "_description", true); ?>
<?php }else{ ?>
<?php } ?></div>
</div>
<?php endwhile; else: ?>
<?php endif; ?>
<div class="navigation">
<?php if (function_exists("pagination")) { pagination($additional_loop->max_num_pages);
} ?></div>
<?php }
我知道它看起来像很多代码,但实际上它们都是非常相似的函数。。。
如何使当前和未来的布道仅显示在第1页上,而不在单击查看旧帖子时显示?