0
嘿,大家我目前非常沮喪,無法弄清楚這一點已經看遍了整個互聯網。我有一個稱爲「投資組合」的自定義帖子類型,我有一個名爲「類別」的分類法,其中包含兩個類別「攝影」和「目錄設計」。我使用這個代碼WordPress的自定義帖子類型和分類仍然顯示帖子類型的所有帖子
query_posts(array(
'post_type' => 'portfolio',
'tax_query' => array(
'taxonomy' => 'category',
'field' => 'catalog-design',
'terms' => 'catalog-design'
)
));
出於某種原因,它不聽分類,並只顯示在投資組合的一切。我也嘗試這樣做,它仍然沒有工作
query_posts(array(
'post_type' => 'portfolio',
'category' => 'catalog-design'
));
如果有人知道如何解決這個問題將是真棒也在這裏是創造一切
add_action('init', 'portfolio');
功能組合(){
代碼$labels = array(
'name' => _x('Portfolio', 'edit and add portfolio items'),
'singular_name' => _x('Portfolio Item', 'post type singular name'),
'add_new' => _x('Add Portfolio Item', 'Portfolio Item'),
'add_new_item' => __('Add New Portfolio Item'),
'edit_item' => __('Edit Portfolio Item'),
'new_item' => __('New Portfolio Item'),
'view_item' => __('View Portfolio'),
'search_items' => __('Search Portfolio'),
'not_found' => __('Nothing found'),
'not_found_in_trash' => __('Nothing found in Trash'),
'parent_item_colon' => ''
);
$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'query_var' => true,
'menu_icon' => get_stylesheet_directory_uri() . '/library/images/portfolio.png',
'rewrite' => true,
'capability_type' => 'post',
'hierarchical' => false,
'menu_position' => null,
'supports' => array('title', 'category', 'editor','thumbnail'),
'taxonomies' => array('category', 'client')
);
register_post_type('portfolio' , $args);
}
這就是我最終找到並得到它的工作。 –