[Resolved] Excerpt only on first page of multipage/paginated posts

Home Forums Support [Resolved] Excerpt only on first page of multipage/paginated posts

Home Forums Support Excerpt only on first page of multipage/paginated posts

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #660859
    Markus

    Hi!

    First let me say, that I’m very happy with GP. It is so well thought-out and yet lightweight.

    But I have one problem with multipage/paginated posts (<!– nextpage –>)

    I inserted the <? the_excerpt(); ?> into a hook element “after_entry_title” which works fine. But I want the excerpt only on the first page of the paginated post.

    If tried

    if ( !is_paged() ) {
     print '<div id="nbexcerpt">';
     the_excerpt();
    print'</div>';
    }

    which doesn’t work (it never displays the excerpt). And also

    <?php $paged = get_query_var( 'paged', 1 ); ?>

    fails.

    Do you have a little hint? It would be also nice, if the featured image show up only on the first page of the post.

    Kind regards,
    Markus

    GeneratePress 2.1.4
    #661347
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    That code should work, but where are you inserting it? On single posts?

    I’m not sure how it relates to <!-- nextpage -->?

    Can you explain a bit more?

    Thanks!

    #661415
    Markus

    Of cause! Here is a long post, splitted into 3 pages via the <!– nextpage –> tag:

    https://nachbelichtet.com/2017/08/06/der-teufel-sorgt-fuers-detail-das-teufel-ultima-40-surround-5-1-set-angetestet/2/

    You can see the pagination at the end of the content.

    I’m using custom excerpts, but I only want to show the excerpt (and maybe the featured image, which is an other question) on the first page of the post.

    If I just insert the <? the_excerpt(); ?> in a hook element at the Posts/All Posts position, the excerpt is visible. But if I insert the code

    if ( !is_paged() ) {
     print '<div id="nbexcerpt">';
     the_excerpt();
    print'</div>';
    }

    the !is_paged() always returns “false” and thus shows the excerpt on every page, instead of page 1.

    Markus

    #661685
    Tom
    Lead Developer
    Lead Developer
    #661899
    Markus

    Unfortunately not – it relies on another posts, but not on “in post pagination”. Nevertheless: Thank you for your efforts!

    Got it! It is simple as that:

    global $page;
    if ($page == 1) {	
     print '<div id="nbexcerpt">';
        the_excerpt();
     print'</div>';
    }

    Maybe it’ll help someone.

    Best regards,
    Markus

    #662447
    Tom
    Lead Developer
    Lead Developer

    Ah, good to know! That’s for sharing your code 🙂

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