Hi,
Thank you, I’m glad you like the theme ??
There is no real easy way around this. You need to copy the receptar_post_nav()
function from the theme to your child theme’s functions.php
file and then modify the get_adjacent_post
WordPress function used within to get links from the same term only.
Basically, just put this into your child theme’s functions.php
file and it should work:
function receptar_post_nav() {
//Requirements check
if ( ! is_singular() || is_page() ) {
return;
}
//Helper variables
$output = $prev_class = $next_class = '';
$previous = ( is_attachment() ) ? ( get_post( get_post()->post_parent ) ) : ( get_adjacent_post( true, '', true ) );
$next = get_adjacent_post( true, '', false );
//Requirements check
if (
( ! $next && ! $previous )
|| ( is_attachment() && 'attachment' == $previous->post_type )
) {
return;
}
$links_count = absint( (bool) $next ) + absint( (bool) $previous );
//Preparing output
if ( $previous && has_post_thumbnail( $previous->ID ) ) {
$prev_class = " has-post-thumbnail";
}
if ( $next && has_post_thumbnail( $next->ID ) ) {
$next_class = " has-post-thumbnail";
}
if ( is_attachment() ) {
$output .= get_previous_post_link(
'<div class="nav-previous nav-link' . esc_attr( $prev_class ) . '">%link</div>',
wp_kses(
__( '<span class="post-title"><span class="meta-nav">Published In: </span>%title</span>', 'receptar' ),
array( 'span' => array( 'class' => array() ) )
)
);
} else {
$output .= get_next_post_link(
'<div class="nav-next nav-link' . esc_attr( $next_class ) . '">%link</div>',
wp_kses(
__( '<span class="post-title"><span class="meta-nav">Next: </span>%title</span>', 'receptar' ),
array( 'span' => array( 'class' => array() ) )
)
);
$output .= get_previous_post_link(
'<div class="nav-previous nav-link' . esc_attr( $prev_class ) . '">%link</div>',
wp_kses(
__( '<span class="post-title"><span class="meta-nav">Previous: </span>%title</span>', 'receptar' ),
array( 'span' => array( 'class' => array() ) )
)
);
}
if ( $output ) {
$output = '<nav class="navigation post-navigation links-count-' . $links_count . '" role="navigation"><h1 class="screen-reader-text">' . esc_html__( 'Post navigation', 'receptar' ) . '</h1><div class="nav-links">' . $output . '</div></nav>';
}
//Output
echo apply_filters( 'wmhook_receptar_post_nav_output', $output );
}
Regards,
Oliver