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:
http://www.sybase-recovery.com/file-splitter/errors/test-error/
rewrite->pages
true?register_post_type()
in the code.