Wordpress 为每个列出的帖子获取分类术语

Wordpress 为每个列出的帖子获取分类术语,wordpress,Wordpress,我有一个最新帖子的列表(自定义帖子类型)。在每个列表项中,我都有帖子的标题和图片。我想展示这个帖子所属的术语名称。我该怎么做呢?在代码中,我有自定义的分类术语名称,我想在这里显示术语 <?php $args = array( 'post_type' => 'lessons', 'posts_per_page' => 4,

我有一个最新帖子的列表(自定义帖子类型)。在每个列表项中,我都有帖子的标题和图片。我想展示这个帖子所属的术语名称。我该怎么做呢?在代码中,我有自定义的分类术语名称,我想在这里显示术语

<?php
                    $args = array( 
                        'post_type' => 'lessons', 
                        'posts_per_page' => 4, 
                        'order'=> 'ASC', 
                        'orderby' => 'title',
                        'taxonomy' => 'lesson-type'
                    );
                    $postslist = get_posts( $args );

                    foreach ( $postslist as $post ) : setup_postdata( $post ); ?>
                        <div class="col-sm-6 col-md-3">
                            <div class="panel panel--lesson">
                                <img src="http://placehold.it/640x360" alt="<?php the_title() ?>" class="video-thumb img-responsive" data-vimeo-id="<?php the_field('vimeo_id') ?>">
                                <div class="panel-body">
                                    <h3><?php the_title() ?></h3>

                                    <ul>
                                        <li><span>Category: CUSTOM TAXONOMY TERM NAME HERE</span> </li>

                                        <?php 
                                            $songDifficulty = get_field('song_difficulty');
                                            if ($songDifficulty > 0) : ?>
                                                <li><span>Song Level:</span> <?php echo $songDifficulty ?></li>
                                            <?php endif; ?>
                                    </ul>

                                    <a href="<?php echo get_permalink(); ?>" class="cta cta--primary cta--chevron-right cta--block">View Lesson</a>
                                </div>
                            </div>
                        </div>
                <?php
                    endforeach; 
                    wp_reset_postdata();
                ?>

“class=”视频拇指img响应“数据vimeo id=”“>
  • 类别:此处为自定义分类术语名称
  • 歌曲级别:
根据,您只需通过以下方式即可获得给定帖子的条款:


$terms=get_the_terms($post->ID);

$terms=get_the_the_the_terms($post->ID);-此外,这应该是打开的,而不是Dan…谢谢你的帮助…它成功了,谢谢你让我知道wordpress.stackexchange.com。我下次会在那里发布。