)我有一個稱爲短期課程的自定義文章類型,並且我已添加一個自定義分類標準以稱爲課程類型,它使我可以對課程進行分類...在頁面模板中顯示特定分類(
我試圖創建一個頁面模板,將顯示一個單一的分類(所有類別)的所有課程。在這種情況下,我想說明,已分配的分類(類)所有課程的Adobe ...香港專業教育學院嘗試了一些不同的東西,但是我的繼承人最新代碼:
<?php
// get the custom post type's taxonomy terms
$custom_taxterms = wp_get_object_terms($post->ID, 'adobe', array('fields' => 'ids'));
// arguments
$args = array(
'post_type' => 'short_courses',
'post_status' => 'publish',
'posts_per_page' => 20, // you may edit this number
'orderby' => 'rand',
'tax_query' => array(
array(
'taxonomy' => 'adobe',
'field' => 'id',
'terms' => $custom_taxterms
)
),
'post__not_in' => array ($post->ID),
);
$related_items = new WP_Query($args);
// loop over query
if ($related_items->have_posts()) :
echo '<ul>';
while ($related_items->have_posts()) : $related_items->the_post();
?>
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php
endwhile;
echo '</ul>';
endif;
// Reset Post Data
wp_reset_postdata();
?>
它不通過任何東西拉。 ..
我曾嘗試使用此代碼太:
<?php
$args = array(
'post_type' => 'short_courses',
'orderby' => 'title',
'order' => 'ASC',
'product_categories' => 'adobe'
);
$the_query = new WP_Query($args);
?>
<?php if ($the_query->have_posts()) : while ($the_query->have_posts()) : $the_query->the_post(); ?>
<?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 the_field('image'); ?>" alt="<?php the_title();?> graphic"></a></p>
<h4><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h4>
<?php $products_count = $the_query->current_post + 1; ?>
<?php if ($products_count % 4 == 0): ?>
<?php endif; ?>
<?php endwhile; endif; ?>
但這個代碼拉通過所有的短期課程,而不僅僅是那些的Adobe ...
任何人都可以電話米我要去哪裏?
似乎並不具有唉效果恐怕@Nkole - 我已經更新了我的代碼,但增加了... –
高興你得到它的工作。那些可能令人沮喪! –