Archived topic
Bug display next/previous button category visual portfolio
5 replies · Started by alexis on March 3, 2021
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
Hi 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 in if ( 'portfolio_category' == get_post_type() ) ?
Let us know.
ok 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 );
You 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;
}
} );
Thanks, perfect !
No problem. :)