【发布时间】:2016-04-29 20:23:23
【问题描述】:
我使用 wordpress 的自定义帖子类型 UI 插件创建了一个名为资源库的自定义帖子类型和一个名为资源类别的自定义分类。我无法查询分类页面模板上的类别。如果有人能帮我解决这个问题,我将不胜感激。
这是我的 taxonomy-resource-categories.php 文件中的代码:
<?php $args = array(
'post_type' => 'resource-library',
'tax_query' => array(
array(
'taxonomy' => 'resource-categories',
'field' => 'slug',
'terms' => 'data-sheets',
),
),
); $query = new WP_Query( $args );
?>
<?php while (have_posts()) : the_post(); ?>
<div class="blog-post-wrap">
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
<div class="post-thumb blog-index">
<?php
if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it.
the_post_thumbnail( 'large' );
}
?>
</div>
<div class="title-meta-wrap">
<?php if (strlen($post->post_title) > 75) {
echo substr(the_title($before = '', $after = '', FALSE), 0, 75) . '...'; } else {
the_title();
} ?>
</a>
<p><span class="theauthor"><?php the_date(); ?> <span style="color:#EC7906;"> / </span><?php the_author(); ?> </span></p>
</div>
</div>
<?php endwhile; ?>
【问题讨论】: