- This topic has 21 replies, 3 voices, and was last updated 3 years, 7 months ago by David.
-
AuthorPosts
-
May 30, 2017 at 9:44 am #326195wekhter
How do you get the built-in generatepress next/previous post links to work on custom post types?
May 30, 2017 at 7:03 pm #326390TomLead DeveloperLead DeveloperTry this:
add_action( 'generate_after_entry_content', 'tu_custom_post_type_post_nav' ); function tu_custom_post_type_post_nav() { if ( 'my-post-type' == get_post_type() ) : ?> <footer class="entry-meta"> <?php generate_entry_meta(); ?> <?php if ( is_single() ) generate_content_nav( 'nav-below' ); ?> </footer><!-- .entry-meta --> <?php endif; }
Adding PHP: https://docs.generatepress.com/article/adding-php/
May 31, 2017 at 4:54 pm #326844wekhterThanks! Another question–is there something I can do to remove next/previous on regular posts, but keep them on my CPT?Also, I found snippets on the forum to edit the text that appears before the next/previous links, but I’d like that text to appear inside the links (so for instance the word “previous” being part of the link instead of being before the link).Nevermind, figured out what I was doing wrong. Will the ability to have more control over page nav be added to GP Premium anytime soon?
June 1, 2017 at 12:06 am #327023TomLead DeveloperLead DeveloperWhat kind of control are you looking for?
June 1, 2017 at 3:38 pm #327409wekhter@Tom Basic sorts of things:
1) Ability to disable next/previous on posts (an option in the blog extension?)
2) Font size
3) Change the text that appears before links
4) Alignment (so for instance, instead of having both left aligned, left align previous and right align next, or center align both on the same line)
June 1, 2017 at 7:17 pm #327481TomLead DeveloperLead DeveloperNoted. Thanks! π
December 26, 2017 at 9:28 am #457283GwenHi,
I’ve added the following to my child theme’s functions.php so there will be next/previous links on “staff” CPT posts. However, all that is rendering on the front-end is
<footer class=”entry-meta”> </footer>Have I missed a step along the way? Thank you!
—–
add_action( 'generate_after_entry_content', 'tu_custom_post_type_post_nav' ); function tu_custom_post_type_post_nav() { if ( 'staff' == get_post_type() ) : ?> <footer class="entry-meta"> <?php generate_entry_meta(); ?> <?php if ( is_single() ) generate_content_nav( 'nav-below' ); ?> </footer><!-- .entry-meta --> <?php endif; }
December 26, 2017 at 7:40 pm #457513TomLead DeveloperLead DeveloperGive this a shot instead:
add_action( 'generate_after_entry_content', 'tu_custom_post_type_post_nav' ); function tu_custom_post_type_post_nav() { if ( 'staff' == get_post_type() ) : ?> <footer class="entry-meta"> <?php generate_content_nav( 'nav-below' ); ?> </footer><!-- .entry-meta --> <?php endif; }
Let me know π
December 28, 2017 at 2:05 pm #458811GwenThanks so much, Tom — that works!!
December 28, 2017 at 10:22 pm #459000TomLead DeveloperLead DeveloperYou’re welcome π
September 2, 2019 at 1:28 am #998888MattHi, How do I remove/disable Next/Previous link at footer? I just upgraded to Pro, but I do not see anything to disable Next/Previous link. Thanks!
September 2, 2019 at 2:24 am #998918DavidStaffCustomer SupportHi there,
you can disable the Display post navigation in Customizer > Layout > Blog:
https://docs.generatepress.com/article/blog-content-layout/#single
September 2, 2019 at 3:09 am #998951MattHi David, thanks. Found another way, much easier posted by jmarc:
CSS >>>
.nav-links { display: none; }
September 2, 2019 at 3:13 am #998953DavidStaffCustomer SupportThat simply hides the nav, doesn’t remove the code from the markup. I am not sure why unchecking a box in the customizer would be more complicated then adding CSS. But if it works for you, then great.
September 2, 2019 at 3:26 am #998968MattTried all that before. Didn’t work. I was only trying to remove the Previous/Next links just above footer.
-
AuthorPosts
- You must be logged in to reply to this topic.