Show category in PreviousNext links

In place of the word PREVIOUS and NEXT, I would like to display the level 2 categories of the respective posts.This is m

In place of the word PREVIOUS and NEXT, I would like to display the level 2 categories of the respective posts.

This is my current code:

function twentyfourteen_post_nav() {
        $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>%title', 'twentyfourteen' ) );
                    next_post_link( '%link', __( '<span class="meta-nav">Next Post</span>%title', 'twentyfourteen' ) );
                endif;
                ?>
            </div><!-- .nav-links -->
        </nav><!-- .navigation -->
        <?php
    }
endif;

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745044923a4608037.html

相关推荐

  • Show category in PreviousNext links

    In place of the word PREVIOUS and NEXT, I would like to display the level 2 categories of the respective posts.This is m

    8小时前
    40

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信