- This topic has 5 replies, 2 voices, and was last updated 3 years, 1 month ago by Elvin.
-
AuthorPosts
-
March 3, 2021 at 3:11 pm #1681048alexis
Hello,
I use the Visual portfolio plugin and on my posts I can’t display the next and previous posts. According to what I see https://wordpress.org/support/topic/next-and-previous-post-links-2/ this is due to the theme setting.
I added this
add_action( 'generate_before_footer', 'tu_custom_post_type_post_nav' ); function tu_custom_post_type_post_nav() { if ( 'portfolio_category' == 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; };
but it doesn’t change anything. In my dasboard it’s well set though and I see the links on another category
March 3, 2021 at 6:00 pm #1681144ElvinStaffCustomer SupportHi there,
I’ve inspected your site and the post type specified on the snippet’s condition doesn’t seem to match the post type slug.
Can you try removing
_category
inif ( 'portfolio_category' == get_post_type() )
?Let us know.
March 4, 2021 at 5:48 am #1681693alexisok it works thank you. And I want to change the button texts. I’ve added all this, but I need to have something duplicate because I have the previous and next navigation bar twice.
add_action( 'generate_before_footer', 'tu_custom_post_type_post_nav' ); function tu_custom_post_type_post_nav() { if ( 'portfolio' == 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_filter( 'next_post_link', function( $output, $format, $link, $post ) { if ( ! $post ) { return ''; } return sprintf( '<div class="nav-next"><span class="next"><a href="%1$s" title="%2$s">Mariage suivant</a></span></div>', get_permalink( $post ), $post->post_title ); }, 10, 4 ); add_filter( 'previous_post_link', function( $output, $format, $link, $post ) { if ( ! $post ) { return ''; } return sprintf( '<div class="nav-previous"><span class="prev"><a href="%1$s" title="%2$s">Mariage précédent</a></span></div>', get_permalink( $post ), $post->post_title ); }, 10, 4 );
March 4, 2021 at 3:24 pm #1682542ElvinStaffCustomer SupportYou can try adding this PHP snippet so the default pagination doesn’t show on portfolio posts types.
add_filter( 'generate_show_post_navigation', function(){ if ( 'portfolio' == get_post_type() ){ return false; } } );
March 5, 2021 at 2:34 am #1682901alexisThanks, perfect !
March 7, 2021 at 4:33 pm #1686001ElvinStaffCustomer SupportNo problem. 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.