[Resolved] Adding Previous/Next links to custom post types

Home Forums Support [Resolved] Adding Previous/Next links to custom post types

Home Forums Support Adding Previous/Next links to custom post types

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #333078
    Mike

    Hello one and all!

    Is there an easy way to add the previous/next links to custom post types? I noticed in a recent changelog there was a new filter added that looks like it has to do with prev/next links. How does one enable that on specific post types?

    All the best,

    Michael

    #333098
    Leo
    Staff
    Customer Support

    Hi there,

    I think those filters are for switching out the next/prev link text itself.

    Will confirm with Tom πŸ™‚

    This should help though: https://generatepress.com/forums/topic/nextprevious-post-links-on-cpt/#post-326390

    #333099
    Mike

    That code worked thank you. Is there a way of adding multiple custom post types into that code as opposed to using the same block of code for different post types?

    I tried adding things, bars, clubs cpt’s into it but it didn’t work:

    add_action( 'generate_after_entry_content', 'tu_custom_post_type_post_nav' );
    function tu_custom_post_type_post_nav() {
    	if ( 'things , bars , clubs' == 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;
    }
    #333104
    Leo
    Staff
    Customer Support

    Try this:

    add_action( 'generate_after_entry_content', 'tu_custom_post_type_post_nav' );
    function tu_custom_post_type_post_nav() {
    	if ( in_array(get_post_type(), array('things','bars','clubs') ) ) : ?>
    		<footer class="entry-meta">
    			<?php generate_entry_meta(); ?>
    			<?php if ( is_single() ) generate_content_nav( 'nav-below' ); ?>
    		</footer><!-- .entry-meta -->
    	<?php endif;
    }
    #333107
    Leo
    Staff
    Customer Support

    Made a mistake. Edited again…

    #333174
    Mike

    Hello Leo,

    Worked like a charm! Thank you, and as ever, this forum provides support beyond reproach πŸ™‚

    All the best,

    Michael

    #333182
    Leo
    Staff
    Customer Support

    You’re very welcome πŸ™‚

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