出于某种原因,当您在我的 wordpress 博客上单击“Previous Posts”时,页面 URL 发生了变化,但前十个帖子再次显示。
您可以在这里看到问题:http: //onedirectionconnection.com/然后是第二页http://onedirectionconnection.com/page/2/#stash.0SQiq9AP.dpbs(这是另一回事 - 我不知道为什么该代码正在添加到下一页 URL 的末尾)...
无论如何,这是我用于保存在名为 front-page.php 的文件中的首页模板的代码
<?php
/*
Template Name: Splash Page
*/
get_header(); ?>
<div id="primary" class="content-area">
<main id="main" class="site-main" role="main">
<div class="section-container">
<h1 class="section-title">Latest News</h1>
</div>
<?php $my_query = new WP_Query('showposts=1'); ?>
<?php while ($my_query->have_posts()) : $my_query->the_post(); ?>
<h1 class="entry-title bottommargin big">
<a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a>
</h1>
<div class="entry-content">
<?php the_content(); ?>
</div>
<div class="row">
<div class="col-md-12">
<footer class="row no-margin">
<div class="col-md-3 meta-entry">
Author: <br>
<?php the_author_link(); ?>
</div>
<div class="col-md-3 meta-entry">
Posted On:<br>
<?php the_time('F j, Y'); ?>
</div>
<div class="col-md-3 meta-entry">
Categorized:<br>
<?php echo get_the_category_list(', '); ?>
</div>
<div class="col-md-3 meta-entry-right">
Discussion:<br>
<a href="<?php comments_link(); ?>"><?php comments_number(); ?></a>
</div>
</footer>
</div>
</div>
<?php endwhile; ?>
<div class="section-container">
<h1 class="section-title">More News</h1>
</div>
<?php
$custom_query = new WP_Query(array(
'posts_per_page' => 10,
'offset' => 1,
'paged' => (get_query_var('paged')) ? get_query_var('paged') : 1
));
?>
<?php while ($custom_query->have_posts()) : $custom_query->the_post(); ?>
<div class="row topmargin">
<div class="col-md-3 no-padding center">
<?php the_post_thumbnail('thumbnail', array('class' => 'img-thumbnail img-responsive')); ?>
</div>
<div class="col-md-9">
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<header class="entry-header">
<h1 class="entry-title">
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a>
</h1>
</header><!-- .entry-header -->
<div class="entry-content">
<?php the_excerpt(); ?>
<?php
wp_link_pages( array(
'before' => '<div class="page-links">' . __( 'Pages:', 'professional1d' ),
'after' => '</div>',
) );
?>
</div><!-- .entry-content -->
</article><!-- #post-## -->
<?php
// If comments are open or we have at least one comment, load up the comment template
if ( comments_open() || '0' != get_comments_number() )
comments_template();
?>
</div>
</div>
<footer class="row no-margin">
<div class="col-md-3 meta-entry">
Author: <br>
<?php the_author_link(); ?>
</div>
<div class="col-md-3 meta-entry">
Posted On:<br>
<?php the_time('F j, Y'); ?>
</div>
<div class="col-md-3 meta-entry">
Categorized:<br>
<?php echo get_the_category_list(', '); ?>
</div>
<div class="col-md-3 meta-entry-right">
Discussion:<br>
<a href="<?php comments_link(); ?>"><?php comments_number(); ?></a>
</div>
</footer>
<?php endwhile; // end of the loop. ?>
<div class="center">
<?php posts_nav_link(); ?>
</div>
</main><!-- #main -->
</div><!-- #primary -->
</div>
<?php get_sidebar(); ?>
<?php get_footer(); ?>
一切看起来都很标准,所以我真的不知道问题是什么。如果有人可以帮助我解决这个问题,将不胜感激!