admin管理员组文章数量:1279117
I am studying how the page splitting is implemented, after inserting in the post.
Currently in my theme, all split pages will show the content of the first page. So I think the issue comes from the single.php template. I check it and below is the codes to display the post content:
<main id="main" class="site-main single-page" role="main">
<section class="wrapper">
<?php /* The loop */ ?>
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<div class="entry">
<?php the_content(''); ?>
<?php if ( is_singular( 'wperrors' ) ) { ?>
<?php wp_link_pages(); ?>
<?php } ?>
</div>
</article>
<?php endwhile; ?>
<?php else : ?>
<?php endif; ?>
</section>
</main><!-- #main -->
Then I install the WordPress default theme, which will display split pages with proper contents. I check its single.php template:
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div <?php post_class(); ?> id="post-<?php the_ID(); ?>">
<h2><?php the_title(); ?></h2>
<div class="entry">
<?php the_content('<p class="serif">' . __('Read the rest of this entry »', 'kubrick') . '</p>'); ?>
<?php wp_link_pages(array('before' => '<p><strong>' . __('Pages:', 'kubrick') . '</strong> ', 'after' => '</p>', 'next_or_number' => 'number')); ?>
<?php } edit_post_link(__('Edit this entry', 'kubrick'),'','.'); ?>
</small>
</p>
</div>
</div>
<?php endwhile; else: ?>
<p><?php _e('Sorry, no posts matched your criteria.', 'kubrick'); ?></p>
<?php endif; ?>
I remove some useless codes related to comments.
The only function that is used to display the content is the_content(), and I check its document but cannot find any information how it is used to retrieve the content of the current split page.
And I compare the codes in these two files and those used to display the contents are actually be the same. So, why the default WP theme can display the proper split page content, while mine cannot?
Note: wperrors is a custom type of post. Currently I only want to support split pages in wperrors posts, so I add the following lines:
<?php if ( is_singular( 'wperrors' ) ) { ?>
<?php wp_link_pages(); ?>
<?php } ?>
so that only wperrors posts will show page links in the footer.
Below is a wperrors post that demonstrates the issue:
/
本文标签: paginationHow is the Page Splitting implemented in the theme
版权声明:本文标题:pagination - How is the Page Splitting implemented in the theme? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741287003a2370329.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论