0
我遇到自定義帖子類型和自定義分類標準的問題。我創建了一個名爲「畫廊」的自定義帖子類型和名爲「gallery_type」的分類法。我創建了一個名爲Gallery的頁面,其中我加載了來自畫廊的所有帖子。然後,我創建了'花園'&'house'分類術語,併爲每個'garden'&'house'分配了3-3個帖子。我把分類術語「花園」和「房子」作爲子菜單鏈接到我當前的父母。我想按他們各自的條款顯示帖子。但它沒有加載。我能做什麼 ?? 我的代碼是:「Wordpress自定義帖子類型和自定義分類標準
$tax = 'gallery_type';
$terms = get_the_terms($post->ID, $tax);
if($terms){
foreach($terms as $term){
$single = $term->name;
?>
<?php
$args = array('post_type'=>'galleries',
'posts_per_page'=> -1,
'tax_query'=>array(
array('taxonomy'=>'gallery_type',
'terms'=> $single)
),
'order_by'=>'post_date');
$query = new WP_Query($args);
if($query->have_posts()){
while($query->have_posts()):
$query->the_post();
$post_id = $post->ID;
?>
<li class="thumb <?php echo $post_id; ?>" onclick="changeContent(<?php echo $post_id; ?>);">
<?php if(has_post_thumbnail())
the_post_thumbnail('gallery-thumb');
?>
<?php
endwhile;
wp_reset_query();
}
else{
_e('No image found in gallery');
}
'
Any fix???