wordpress - 无法在页面上显示自定义帖子类型类别
问题描述
我有一个名为“case_studies”的自定义帖子类型,它有 3 个类别:“seo”、“website-design”和“facebook-advertising”。
我在主页上有几个帖子,对于每个帖子,我想输出帖子的类别。
例如,最新的帖子有“seo”和“facebook-advertising”的类别,我希望它显示在页面中。
我试过 get_the_terms(); 功能,但我认为我使用不正确。
这是页面的代码:
<div class="container">
<!--
<div class="category_container">
<p class="category_item" id="all">All</p>
<p class="category_item" id="website">Websites</p>
<p class="category_item" id="facebook">Facebook Ads</p>
<p class="category_item" id="seo">SEO</p>
</div>
-->
<div class="row d-flex">
<?php
$args1 = array( 'post_type' => array('case_studies'), 'order' => 'DESC', 'posts_per_page' => 30, 'orderby' => 'date' );
$loop = new WP_Query( $args1 );
while ( $loop->have_posts() ) {
$loop->the_post();
$feat_image = wp_get_attachment_url( get_post_thumbnail_id($loop->ID));
?>
<div class="col-sm-4">
<div class="case-study-content">
<a href="<?php the_permalink() ?>" class="blog_blocks">
<div class="b_image">
<img src="<?php echo get_the_post_thumbnail_url(); ?>"/>
</div>
<div class="b_h_sec">
<h2><?php the_title(); ?></h2>
<p><?php echo wp_strip_all_tags( get_the_excerpt(), true ); ?></p>
<span class="r_m">Read More</span>
</div>
</a>
</div>
</div>
<?php } ?>
<?php wp_reset_postdata(); ?>
</div>
</div>
这是输出现在的样子以及我希望在哪里显示类别。
解决方案
推荐阅读
- c# - 使用 ExecuteNonQuery c# 时出错
- javascript - javascript setTimeout - 在 chrome 控制台中不起作用
- python - 在本地保存 requests.get() 响应以在 Beautiful Soup 中使用
- python - 如何在不使用 Sequential() 的情况下在 Keras 中堆叠图层?
- ruby-on-rails - 如何在用户机器上创建文件而不是在服务器中创建然后使用 rails 下载
- windows-10 - Unable to Update the SCCM Consol
- angular - import * as someName from '@angular/core' in angular 2/4/5/6/latter 版本
- ios - 在两个纬度和经度之间绘制折线
- sbt - 从 ScalaJs 调用旋转模板
- javascript - 为什么html音频自动播放不起作用