我已经为公文包循环创建了自定义帖子类型和分类:
// Portfolio CPT
function portfolio_cpt() {
$labels = array(
\'name\' => _x( \'Potfolio Items\', \'post type general name\' ),
\'singular_name\' => _x( \'Portfolio item\', \'post type singular name\' ),
\'menu_name\' => \'Portfolio Items\'
);
$args = array(
\'labels\' => $labels,
\'description\' => \'Portfolio items\',
\'public\' => true,
\'menu_position\' => 5,
\'supports\' => array( \'title\', \'editor\', \'thumbnail\', \'excerpt\', \'comments\' ),
\'has_archive\' => true,
);
register_post_type( \'portfolio\', $args );
}
add_action( \'init\', \'portfolio_cpt\' );
function portfolio_tax() {
$labels = array(
\'name\' => _x( \'Portfolio Categories\', \'taxonomy general name\' ),
\'singular_name\' => _x( \'Portfolio Category\', \'taxonomy singular name\' ),
\'menu_name\' => __( \'Portfolio Categories\' ),
);
$args = array(
\'labels\' => $labels,
\'hierarchical\' => true,
);
register_taxonomy( \'portfolio_category\', \'portfolio\', $args );
}
add_action( \'init\', \'portfolio_tax\', 0 );
这段代码位于单个帖子页面中,因此当我单击一个类别时,它会将我发送到类别存档页面:
<?php
$taxonomy = \'portfolio_category\';
$terms = get_terms($taxonomy);
if ( $terms && !is_wp_error( $terms ) ) :
?>
<ul>
<?php foreach ( $terms as $term ) { ?>
<li><a href="<?php echo get_term_link($term->slug, $taxonomy); ?>"><?php echo $term->name; ?></a></li>
<?php } ?>
</ul>
<?php endif;?>
然后创建了一个名为
archive-portfolio.php
列出与特定类别相关的职位。
问题是,它似乎仍在使用默认的存档模板,这意味着我无法编辑/设置页面样式
有什么想法吗?