0
蔭使用自定義分類任何自定義信息type.If我的類目點擊使用創建texanomy.It導航到分類模板,但顯示所選category.Can一無所知交任何一項幫助我。 顯示URL作爲URL // portfolio_category /蟋蟀/分類模板沒有顯示使用have_posts()爲自定義後
function.php
add_action('init', 'create_team_post_type');
function create_team_post_type() {
register_post_type('portfolio',
array(
'labels' => array(
'name' => __('Portfolio'),
'singular_name' => __('Portfolio')
),
'publicly_queryable' => true,
'show_ui' => true,
'query_var' => true,
'rewrite' => true,
'capability_type' => 'post',
'hierarchical' => false,
'menu_position' => null,
'taxonomies' => array('portfolio_category'),
'supports' => array('title','editor','thumbnail')
)
);
}
function taxonomies_portfolio() {
$labels = array(
'name' => _x('Portfolio categories', 'taxonomy general name'),
'singular_name' => _x('Portfolio categories', 'taxonomy singular name'),
'search_items' => __('Query portfolio categories'),
'all_items' => __('All portfolio categories'),
'parent_item' => __('Parent category'),
'parent_item_colon' => __('Parent category:'),
'edit_item' => __('Edit portfolio category'),
'update_item' => __('Update portfolio category'),
'add_new_item' => __('Add Edit portfolio category'),
'new_item_name' => __('New portfolio category'),
'menu_name' => __('Categories'),
);
$args = array(
'labels' => $labels,
'hierarchical' => true,
'rewrite' => true
);
register_taxonomy('portfolio_category', 'portfolio', $args);
}
add_action('init', 'taxonomies_portfolio', 0);
的index.php
<?php
$defaults = array(
'hide_empty' => false,
'taxonomy' => 'portfolio_category',
'title_li' => __('Categories')
);
wp_list_categories($defaults); ?>
分類法portfolio_category.php
<?php
if(have_posts()):while(have_posts()):the_post();
the_title();
endwhile;
endif;
?>
我需要this.How解決方案可以用我分類filted後按類別。
我不想顯示所有帖子,我只想選擇的類別帖子。如果我在index.php中選擇一個類別。結果將顯示在taxonimy-template.Thats我需要 –
@VijayKumarB你執行代碼在你的taxonomy-portfolio_category.php?你見過結果嗎? –
ya.But它顯示所有posts.Not所選類別崗位。 –