Archived topic
Add previous / next links to CPT single posts - found support topic 2017
7 replies · Started by Brad on February 24, 2022
There's probably an efficient way to do this via GenerateBlocks - New Element - Block (? For a function / echo line of php)- Hook
Display on CPT
This isn't working. it's amended from the 2017 post which dragged out to 2020.
Note: I'm using GenerateBlocks the replace the Content Template of the archive CPT pages. Not sure if that screws things up. It's just content thrown in after one hook, yes?
add_action( 'generate_after_entry_content', 'j66co_cpt_showcase_post_nav' );
function j66co_cpt_showcase_post_nav() {
if ( 'showcase' == 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;
}
add_action( 'generate_after_entry_content', 'j66co_cpt_photography_post_nav' );
function j66co_cpt_photography_post_nav() {
if ( 'showcase' == 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;
}
https://generatepress.com/forums/topic/nextprevious-post-links-on-cpt/
I figured this out. You can do this in GenerateBlocks. No need to code.
Option in Post Meta - choose next post… etc
https://docs.generatepress.com/article/block-element-post-meta-template/
Glad you figured it out :)
Only found previous next PAGE of post in Generate Blocks… please see link. any ideas. I spoke too soon.
https://www.dropbox.com/s/a3jnc59mfow86mj/Previous-next.jpg?dl=0
I spoke too soon! Sincere apologies. any ideas?
https://www.dropbox.com/s/a3jnc59mfow86mj/Previous-next.jpg?dl=0
Hi Brad,
Block Element - Post navigation may be more appropriate.
https://docs.generatepress.com/article/block-element-post-navigation/
Can you give it a try?
Sincere thanks! Perfect tutorial. Just used a template for now to get it working.
Idea. Not sure if there’s a tutorial section on support within search but that my help everyone out. Maybe filter select options one could check? You guys have over a decade of support post though so I’m not sure if something like facet Wp and searchwp would be hard to implement.
There have been attempts to implement these and I think they had some level of success.
I believe it's just a matter of knowing what function renders the toggles and filters and hooking them in through GP specific hooks.
But as for the specifics, it may require asking their developers on what to use.