Site logo

Archived topic

Excerpt only on first page of multipage/paginated posts

5 replies · Started by Markus on August 27, 2018

Viewing posts 1–6 of 6

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

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!

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

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

Ah, good to know! That's for sharing your code :)

This archived topic is closed to new replies.