0
我爲自己的網站上的頁面製作了自定義字段等的自定義帖子類型......目前它正常工作並顯示我創建的所有課程:http://seedcreativehub.co.uk/book-seedcreativehub-courses/僅在Wordpress自定義帖子類型頁面上顯示一個類別
但是,我現在只想讓頁面顯示一個特定的課程類別。
我使用的代碼在下面,我認爲它會像在'category_name'=>'即將發生的事件'中添加帖子類型一樣簡單,但它似乎沒有顯示任何內容在所有...
我不能認爲我做錯了,如果有人可以幫助,這將不勝感激。
<?php
$args = array(
'post_type' => 'courses',
'category_name' => 'upcoming-event'
);
$the_query = new WP_Query($args);
?>
<?php if (have_posts()) : while ($the_query->have_posts()) : $the_query->the_post(); ?>
<div class="col-xs-3 course">
<?php
$thumbnail_id = get_post_thumbnail_id();
$thumbnail_url = wp_get_attachment_image_src($thumbnail_id, 'thumbnail-size', true);
?>
<p><a href="<?php the_permalink(); ?>"><img src="<?php echo $thumbnail_url[0]; ?>" alt="<?php the_title(); ?>" graphic></a></p>
<h3><?php the_field('event_date'); ?></h3>
<h4><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h4>
</div>
<?php $portfolio_count = $the_query->current_post + 1; ?>
<?php if ($portfolio_count % 4 == 0): ?>
</div><div class="row">
<?php endif; ?>
<?php endwhile; endif; ?>
感謝您看,
肖恩。
看看這個:https://codex.wordpress.org/Class_Reference/WP_Query#Taxonomy_Parameters – DaMaGeX