我已经创建了自定义帖子类型和自定义分类法。
/* Custom post type */
function create_post_type() {
/* models */
register_post_type( \'models\',
array(
\'labels\' => array(
\'name\' => __( \'Our Models\' ),
\'add_new\' => \'Add Model\',
\'singular_name\' => _x(\'models\', \'models\')
),
\'public\' => true,
\'menu_position\' => 58,
\'supports\' => array(\'title\', \'editor\',\'thumbnail\'),
\'rewrite\' => array(\'slug\' => \'models\'),
)
);
}
add_action( \'init\', \'create_post_type\' );
/* Custom Taxonomy */
function create_my_taxonomies() {
register_taxonomy( \'models_categories\', \'models\',
array(
\'labels\' => array(
\'name\' => \'Our Models\',
\'singular_name\' => \'Our Model\',
\'search_items\' => \'Search Our Models\',
\'all_items\' => \'All Models\',
\'edit_item\' => \'Edit Models\',
\'update_item\' => \'Update Model\',
\'add_new_item\' => \'Add New Model\',
\'new_item_name\' => \'New Model Name\',
\'menu_name\' => \'Our Models\',
),
\'hierarchical\' => true,
\'sort\' => true,
\'args\' => array( \'orderby\' => \'term_order\' ),
\'rewrite\' => array( \'slug\' => \'our-models\' ),
\'show_admin_column\' => true
)
);
}
add_action( \'init\', \'create_my_taxonomies\', 0 );
然后我创建了一个模板来显示自定义分类法模板名称是
archive-models.php
下面是我在此模板中的代码。它工作正常。
<?php foreach (get_terms(\'models_categories\') as $cat) : ?>
<div class="col-xs-12 col-sm-6 col-md-3 col-lg-3">
<div class="solutions-we-are-expert-in wow fadeInUp animated" data-wow-delay=".1s">
<img src="<?php echo z_taxonomy_image_url($cat->term_id); ?>" class="img-responsive" />
<h1><a href="<?php echo get_term_link($cat->slug, \'models_categories\'); ?>"><?php echo $cat->name; ?></a></h1>
</div>
</div>
<?php endforeach; ?>
现在,问题是,当我单击在此自定义分类法中创建的任何类别时,它应该显示该类别下发布的所有帖子,然后它应该分别转到帖子详细信息页面。我想我对模板层次结构感到困惑。
请协助。