使用第四个参数$excluded\\u termshttp://codex.wordpress.org/Function_Reference/next_post_link
<?php next_post_link( $format, $next, $in_same_term = true, $excluded_terms = \'402\', $taxonomy = \'category\' ); ?>
与上一个\\u post\\u链接相同
http://codex.wordpress.org/Template_Tags/previous_post_link$previous = \'<span class="meta-nav">Previous Post</span>\';
$next = \'<span class="meta-nav">Next Post</span>\';
<?php previous_post_link( $format, $previous, $in_same_term = true, $excluded_terms = \'402\', $taxonomy = \'category\' ); ?>
或者,您可以创建一个模板标记,如whats included in Twenty 14
if ( ! function_exists( \'twentyfourteen_post_nav\' ) ) :
/**
* Display navigation to next/previous post when applicable.
*
* @since Twenty Fourteen 1.0
*/
function twentyfourteen_post_nav() {
// Don\'t print empty markup if there\'s nowhere to navigate.
$previous = ( is_attachment() ) ? get_post( get_post()->post_parent ) : get_adjacent_post( false, \'\', true );
$next = get_adjacent_post( false, \'\', false );
if ( ! $next && ! $previous ) {
return;
}
?>
<nav class="navigation post-navigation" role="navigation">
<h1 class="screen-reader-text"><?php _e( \'Post navigation\', \'twentyfourteen\' ); ?></h1>
<div class="nav-links">
<?php
if ( is_attachment() ) :
previous_post_link( \'%link\', __( \'<span class="meta-nav">Published In</span>%title\', \'twentyfourteen\' ) );
else :
previous_post_link( \'%link\', __( \'<span class="meta-nav">Previous Post</span>\', \'twentyfourteen\' ) );
next_post_link( \'%link\', __( \'<span class="meta-nav">Next Post</span>\', \'twentyfourteen\' ) );
endif;
?>
</div><!-- .nav-links -->
</nav><!-- .navigation -->
<?php
}
endif;