pagination – How is the Page Splitting implemented in the theme?


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 } ?>            
    <?php endwhile; ?>
    <?php else : ?>
    <?php endif; ?>
</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 &raquo;', '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'),'','.'); ?>



    <?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?

alancc 2 weeks 2021-10-04T17:33:40-05:00 0 Answers 0 views 0

Leave an answer