您好如何在自定义帖子类型组合中添加类别或标签?示例徽标,名片等
这是我目前在我的functions.php
中的内容
<?php
add_action('init', 'portfolio_register');
function portfolio_register() {
$args = array(
'label' => __('Portfolio'),
'singular_label' => __('Project'),
'public' => true,
'show_ui' => true,
'capability_type' => 'post',
'hierarchical' => false,
'rewrite' => true,
'supports' => array('title', 'editor', 'thumbnail', 'categories' )
); flush_rewrite_rules();
register_post_type( 'portfolio' , $args );
并在我的template.php页面上
$args = array(
'post_type' => 'portfolio',
'posts_per_page' => $num_posts
);
$query = new WP_Query( $args );
?>
<?php if( $query->have_posts() ) : while( $query->have_posts() ) : $query->the_post(); ?>
<article>
<div class="image fit">
<?php the_post_thumbnail(); ?>
</div>
<header>
<h3><?php the_title(); ?></h3>
<p><?php the_tags ( ', ' ); ?>.</p>
</header>
<footer>
<a href="<?php the_permalink(); ?>" class="btn btn-success">More</a>
</footer>
</article>
<?php endwhile; endif; wp_reset_postdata(); ?>
请告诉我最佳解决方案。提前谢谢