Support » Theme: Author » Split posts

  • Resolved galinaivvn

    (@galinaivvn)



    Hello,
    I want to split my posts to pages after X paragraphs or automatically and to have pagination after post, like a book, but adding <!–nextpage–> tag is not an option, because I have long texts.
    I used this in content.php but there is no pagination or nex page.
    <?php echo wp_trim_words(get_the_content(), 500 ,'<!–nextpage–>’); ?>
    <?php wp_link_pages(); ?>
    Please help

Viewing 7 replies - 1 through 7 (of 7 total)
  • Theme Author Ben Sibley

    (@bensibley)

    Thanks for using Author!

    Is there a reason it needs to be done automatically?

    The <!–nextpage–> tag will work if inserted manually, but I’m asking this because writing a function to automatically insert a series of <!–nextpage–> tags is going to be more challenging.

    The wp_trim_words() function is going to return the first 500 words, but this could be in the middle of a paragraph rather than at a more natural breakpoint. It also only outputs the first 500 words, so a function would need to be written to iterate over the post content and output the next 500 words, and so on until the post is complete.

    Manually adding the <!–nextpage–> tags provides much more artistic control so you can choose better timing in the text to transition to the next page.

    galinaivvn

    (@galinaivvn)

    Hi, @bensibley,
    The reason is that I have too long texts like a novels and it would be hard to put tag manualy

    Theme Author Ben Sibley

    (@bensibley)

    Okay I see. I would recommend trying a plugin for this first. Maybe something like this: https://wordpress.org/plugins/automatically-paginate-posts/

    galinaivvn

    (@galinaivvn)

    I tried it, but it doesn’t work. May be something in theme’s code.
    Do I have to remove this from content.php or something else:
    <?php wp_link_pages( array( ‘before’ => ‘<p class=”singular-pagination”>’ . esc_html__( ‘Pages:’, ‘author’ ), ‘after’ => ‘</p>’, ) ); ?>

    It’s not a problem to use plugin, but tried maybe 20 and no one works with theme

    Theme Author Ben Sibley

    (@bensibley)

    It is standard for all themes to include the wp_link_pages() function, so I would expect the plugins to be compatible with that. However, without seeing the plugin code I can’t know for sure, so it is worth trying. That function can be safely removed from the content.php file in Author without causing any errors.

    galinaivvn

    (@galinaivvn)

    Nothing happens with that plugin. Tried to remove and to put back wp_link_pages() function and still nothing.
    May be this one: https://wordpress.org/plugins/malinky-ajax-pagination/
    but I need: ‘Posts Selector’ The selector that wraps all of the posts/products.
    ‘Post Selector’ The selector of an individual post/product.
    ‘Navigation Selector’ The selector of the post/product navigation.
    ‘Next Selector’ The selector of the navigation next link.

    Theme Author Ben Sibley

    (@bensibley)

    I think that plugin is designed to auto-load posts and replace the pagination on the blog rather than pagination within a single post.

    It is possible to automate this and iterate over the post 500 words at a time, but it will be very difficult to prevent it from breaking up the post in the middle of sentences.

    Since there doesn’t seem to be a pre-made solution for this and the functionality will be complex to create, I think a manual approach is going to be best.

Viewing 7 replies - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.