0

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 &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'),'','.'); ?>

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

8
  • What is wperrors? Commented Oct 5, 2021 at 3:24
  • @JacobPeattie, Thank you for your comment. wperrors is a custom type of post. I have added the information about it in the update section.
    – alancc
    Commented Oct 5, 2021 at 5:40
  • What are the arguments you're using to register the post type? Is rewrite->pages true? Commented Oct 5, 2021 at 5:42
  • @JacobPeattie, where will the post type be registered? The code is not written by me and the original developer refuses to reply my questions. So I am trying to understand his codes.
    – alancc
    Commented Oct 5, 2021 at 5:46
  • Look for register_post_type() in the code. Commented Oct 5, 2021 at 5:54

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.