WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Getting content from a single *page* of a post (5 posts)

  1. matthew78
    Member
    Posted 2 years ago #

    I was googling and searcing Codex for the past half hour, but can't find it:

    What function can I use to fetch content of a single page within a post.
    Let's say I want to split my post to 5 pages - how can I get content of, say, page 3?

  2. egill
    Member
    Posted 2 years ago #

  3. matthew78
    Member
    Posted 2 years ago #

    Thanks, but that wasn't what I was looking for, tho.

    For future Googlers, there doesn't seem to be a specific function, but here is something similar and simple:

    $content_full = apply_filters('the_content', $post->post_content);
    $content = explode("<!--nextpage-->", $content_full);
    $page = count($content);
    echo $page[$i];
  4. egill
    Member
    Posted 2 years ago #

    Ah sorry, I misread you. In order to get content of page 3, all you need to do is add the page parameter to the query.

    global $query_string;
    query_posts($query_string . "&page=3");
    while ( have_posts() ) : the_post();
  5. matthew78
    Member
    Posted 2 years ago #

    Thanks!

Topic Closed

This topic has been closed to new replies.

About this Topic