【发布时间】:2018-04-26 15:16:04
【问题描述】:
我正在尝试创建一个自定义页面模板,该模板可以在单个分类术语下提取帖子列表。
我有一个自定义帖子类型(下载) 和自定义分类(download_type)
我希望以下代码仅从 download_type 分类中提取术语“模型”内的帖子。
<?php $args = array (
'post_type' => 'download'
);
$the_query = new WP_Query($args);
?>
<?php $i = 1; ?>
<?php if ($the_query->have_posts() ): while ($the_query->have_posts() && $i < 5) :$the_query->the_post(); ?>
<a href="<?php the_permalink(); ?>">
<div class="fullwidth_download" style="background-image: url('<?php the_post_thumbnail_url(); ?>')">
<div class="item_meta">
<h2><?php the_title(); ?></h2>
<h3 class="item_price">£<?php the_field('item_price'); ?></h3>
<?php
// vars
$file_type = get_field('file_type');
// check
if( $file_type ): ?>
<ul class="file_types">
<?php foreach( $file_type as $file_type ): ?>
<li><?php echo $file_type; ?></li>
<?php endforeach; ?>
</ul>
</div>
<?php endif; ?>
【问题讨论】: