如何与“下一篇”和“上一篇” WP一起显示类别[编辑]

时间:2019-10-30 18:48:36

标签: wordpress

我的帖子被标记在城市类别中(该类别的上层类别是:国家/地区)。

- Country
-- State
--- City

我希望将2级( State )类别与相应的帖子一起显示,用相应的类别( State )。

image Previous/Next post link

纽约-以前的帖子标题

佛罗里达-下一篇文章标题

我想在twentyfourteen_post_nav()中对主题TwentyFourteen进行改编:

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;

0 个答案:

没有答案