- This topic has 5 replies, 2 voices, and was last updated 3 years, 8 months ago by
Tom.
-
AuthorPosts
-
August 27, 2018 at 1:07 am #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,
MarkusGeneratePress 2.1.4August 27, 2018 at 10:21 am #661347Tom
Lead DeveloperLead DeveloperHi 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!
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentAugust 27, 2018 at 11:31 am #661415Markus
Of cause! Here is a long post, splitted into 3 pages via the <!– nextpage –> tag:
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
August 27, 2018 at 4:40 pm #661685Tom
Lead DeveloperLead DeveloperI believe
is_paged()
is for archives.This might help: https://wordpress.stackexchange.com/a/9223/90661
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-developmentAugust 28, 2018 at 1:30 am #661899Markus
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,
MarkusAugust 28, 2018 at 10:11 am #662447Tom
Lead DeveloperLead DeveloperAh, good to know! That’s for sharing your code 🙂
Documentation: http://docs.generatepress.com/
Adding CSS: http://docs.generatepress.com/article/adding-css/
Ongoing Development: https://generatepress.com/ongoing-development -
AuthorPosts
- You must be logged in to reply to this topic.