分页对我的主页不起作用,但对我的归档页面起作用,我已经检查过了,我的主页不是静态页面,有什么建议可以解决这个问题吗?
下面是我的索引。php
<?php get_header(); global $buzz_options,$buzz_options2; ?>
<!--Mid Counter Start Here -->
<section class="mid-counter">
<div class="container">
<?php //buzz_before_panel(); ?>
<div class="left-panel">
<div class="left-panel-inside">
<?php if($buzz_options2[\'ticker\'][\'home_enable\']){ echo buzz_news_ticker(); } ?>
<?php buzz_home_top_ads(); ?>
<div class="top-article">
<?php global $buzz_used_posts; $featured = get_posts(array(\'tag\' => $buzz_options[\'featured_tax\'],\'posts_per_page\'=>3,\'exclude\' => $buzz_used_posts)); ?>
<div class="top-article-left">
<?php $c=1; $article_class=\'\'; foreach($featured as $post) : setup_postdata( $post ); $post_id = get_the_ID(); $buzz_used_posts[] = $post_id;
if($c==2){ echo \'</div> <div class="top-article-right">\'; }
if($c > 1){ $article_class=\'top-article-one\'; }
?>
<?php if($c==1): ?>
<?php include( locate_template( \'template-parts/content-posts.php\') ); ?>
<?php else : ?>
<?php include( locate_template( \'template-parts/content-posts2.php\') ); ?>
<?php endif; ?>
<?php $c++; endforeach; wp_reset_postdata(); ?>
</div>
</div>
<?php buzz_home_bottom_ads(); ?>
<div class="bot-article">
<?php global $buzz_used_posts; $featured2 = get_posts( array(\'tag\' => $buzz_options[\'featured_tax\'] , \'posts_per_page\'=>4,\'offset\'=>3,\'exclude\' => $buzz_used_posts)); ?>
<?php $c=1; $article_class=\'buzz_bg_cover top-article-one bot-article-loop\'; foreach($featured2 as $post) : setup_postdata( $post ); $post_id = get_the_ID(); $buzz_used_posts[] = $post_id; ?>
<?php include( locate_template( \'template-parts/content-posts2.php\') ); ?>
<?php $c++; endforeach; wp_reset_postdata();?>
</div>
</div>
<?php buzz_middle_sidebar(); ?>
<?php $picks_term = get_term_by(\'slug\',$buzz_options[\'picks_tax\'],\'post_tag\'); ?>
<?php buzz_before_editor_picks(); ?>
<div class="faverate-art editors-picks">
<h2>Editors Picks <em>Our Favourite <a href="http://mywebsite.com/topics/" style="text-decoration: none"><font color="#939393">Articles</font></a></em> <span><a href="<?php echo get_term_link($buzz_options[\'picks_tax\'],\'post_tag\'); ?>" title="See All">See All</a></span></h2>
<div class="faverate-art-inside">
<?php global $buzz_used_posts; $editor_picks = get_posts(array(\'tag\' => $buzz_options[\'picks_tax\'], \'posts_per_page\' =>3,\'exclude\' => $buzz_used_posts)); ?>
<?php $c=1; $article_class=\'faverate-art-loop\'; foreach($editor_picks as $post) : setup_postdata( $post ); $post_id = get_the_ID(); $buzz_used_posts[] = $post_id; ?>
<?php include( locate_template( \'template-parts/content-posts4.php\') ); ?>
<?php $c++; endforeach; wp_reset_postdata();?>
</div>
</div>
<div class="faverate-art latest-posts">
<h1>LATEST NEWS</h1>
<div class="faverate-art-inside latest_posts">
<?php global $buzz_used_posts,$latest_query; $c=1; $latest_query = new WP_Query; $latest_posts = $latest_query->query( array(\'posts_per_page\' => 60,\'post__not_in\' => $buzz_used_posts,\'paged\' => 1)); ?>
<?php $article_class=\'faverate-art-loop\'; foreach($latest_posts as $post) : setup_postdata( $post ); $post_id = get_the_ID(); $buzz_used_posts[] = $post_id; ?>
<?php if($c==4){ buzz_between_latest_news(); } ?>
<?php include( locate_template( \'template-parts/content-posts4.php\') ); ?>
<?php $c++; endforeach; wp_reset_postdata();?>
</div>
<!-- <div id="buzz-loadmore" class="load-more">
<img src="<?php echo MYWEBSITE_THEME_URI; ?>/images/ring-alt.svg" />
<a title="Loading more Stories">Loading more Stories</a>
<div></div>
</div> -->
</div>
</div>
<?php echo get_sidebar(\'home\'); ?>
</div>
</section>
<!--Mid Counter End Here -->
<?php get_footer(); ?>
我也有来自WP初学者的函数。php
function wpbeginner_numeric_posts_nav() {
if( is_singular() )
return false;
global $wp_query;
/** Stop execution if there\'s only 1 page */
if( $wp_query->max_num_pages <= 1 )
return false;
$paged = get_query_var( \'paged\' ) ? absint( get_query_var( \'paged\' ) ) : 1;
$max = intval( $wp_query->max_num_pages );
/** Add current page to the array */
if ( $paged >= 1 )
$links[] = $paged;
/** Add the pages around the current page to the array */
if ( $paged >= 3 ) {
$links[] = $paged - 1;
$links[] = $paged - 2;
}
if ( ( $paged + 2 ) <= $max ) {
$links[] = $paged + 2;
$links[] = $paged + 1;
}
echo \'<div class="navigation"><ul>\' . "\\n";
/** Previous Post Link */
if ( get_previous_posts_link() )
printf( \'<li>%s</li>\' . "\\n", get_previous_posts_link() );
/** Link to first page, plus ellipses if necessary */
if ( ! in_array( 1, $links ) ) {
$class = 1 == $paged ? \' class="active"\' : \'\';
printf( \'<li%s><a href="%s">%s</a></li>\' . "\\n", $class, esc_url( get_pagenum_link( 1 ) ), \'1\' );
if ( ! in_array( 2, $links ) )
echo \'<li>…</li>\';
}
/** Link to current page, plus 2 pages in either direction if necessary */
sort( $links );
foreach ( (array) $links as $link ) {
$class = $paged == $link ? \' class="active"\' : \'\';
printf( \'<li%s><a href="%s">%s</a></li>\' . "\\n", $class, esc_url( get_pagenum_link( $link ) ), $link );
}
/** Link to last page, plus ellipses if necessary */
if ( ! in_array( $max, $links ) ) {
if ( ! in_array( $max - 1, $links ) )
echo \'<li>…</li>\' . "\\n";
$class = $paged == $max ? \' class="active"\' : \'\';
printf( \'<li%s><a href="%s">%s</a></li>\' . "\\n", $class, esc_url( get_pagenum_link( $max ) ), $max );
}
/** Next Post Link */
if ( get_next_posts_link() )
printf( \'<li>%s</li>\' . "\\n", get_next_posts_link() );
echo \'</ul></div>\' . "\\n";
}