我正在开发的WordPress主题上有几个自定义帖子类型 . 每种帖子类型都有一些自定义分类 . 我正在使用自定义帖子类型ui插件 . 我为每个自定义帖子类型创建了一个帖子模板 . 我试图在顶部的某个位置添加自定义,以便仅在该特定分类的自定义帖子类型之间导航 . 因此,如果它是美国汽车定制的邮政类型,那么分类法是与福特,雪佛兰等制作我想在这些之间导航 . 我挂断的地方是在循环中向当前帖子中添加一个active类 . 当然,WordPress主菜单为您提供了一类活动或当前项目,因此您可以设置当前项目的样式,这就是我想要实现的 . 这是我尝试过的事情之一,我最终得到了一个对所有项目都有效的类...

<div class="row">
        <?php $temp = get_the_ID(); ?>
            <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
                <?php $class = ( $temp == get_the_ID() ) ? 'active' : ''; ?>
            <div class="large-10 columns large-offset-1">
            <h2><?php the_title(); ?></h2>
            <div class="large-8 columns slider">
                <div class="models text-center">

start nav menu
                    <ul class="inline-list text-center"> 
                    <?php if( has_term( 'my-term', 'model' ) ) :  ?>
                        <li><a href="<?php echo get_post_type_archive_link( 'my-archive' ); ?>">My Link:</a></li>
                        <li><a class="<?php echo $class ?>" href="<?php echo get_page_uri( '63' ); ?>">Taxonomy Item 1</a></li>
                    <li><a class="<?php echo $class ?>" href="<?php echo get_page_uri( '64' ); ?>">Taxonomy Item 2</a></li> 
                    <?php  else:  ?>
                        other stuff here
                    <?php   endif; ?>       
                    </ul>
                </div>
                <div class="thumb-slider"><?php the_field('thumb_slider'); ?></div>
                <div class="single-description"><?php the_field('single_description'); ?></div>
            </div>
            <div class="large-4 columns">
                <div class="content">
                    <div class="spec-wrapper">
                        <h4>Specs</h4>
                        <?php the_field('specs'); ?>
                    </div>
                </div>          
            </div>
            </div>
            <?php endwhile; else : ?>

                <p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p>
            <?php endif; ?>
        </div>