-1
我以'手机'的名义创建了自定义帖子类型。在类别中,我有4个品牌名称,我希望每个电话在类别页面中都有一个类别。我的自定义帖子类型根据wordpress中的类别未显示
我的功能代码:
function create_phone_post_type() {
register_post_type('phones',
array(
'labels' => array(
'name' => 'phones',
'singular_name' => 'phones',
'add_new' => 'Add New',
'add_new_item' => 'Add New phone',
'edit_item' => 'Edit phone',
'new_item' => 'New phone',
'view_item' => 'View phone',
'search_items' => 'Search phone',
'not_found' => 'Nothing Found',
'not_found_in_trash' => 'Nothing found in the Trash',
'parent_item_colon' => ''
),
'taxonomies' => array('category',),
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'query_var' => true,
'has_archive' => true,
'capability_type' => 'post',
'hierarchical' => false,
'menu_position' => null,
'supports' => array('title',
'editor',
'excerpt',
'trackbacks',
'custom-fields',
'comments',
'revisions',
'thumbnail',
'author',
'page-attributes',)
)
);
}
add_action('init', 'create_phone_post_type');
和分类页面:
<?php if(have_posts()) : ?>
<div class="title_page_category">
<h5> <?php printf(__('Category: %s', 'anaximander'), '<span>' . single_cat_title('', true) . '</span>');?></h5>
</div>
<?php
$args = array('post_type' => 'phones',
'posts_per_page' => 20);
$loop = new WP_Query($args);
while ($loop->have_posts()) : $loop->the_post();?>
<div class="col-lg-3">
<div class="phone_thumbnail">
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" >
<?php the_post_thumbnail(); ?>
</a>
</div>
<div class="phone_title">
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" >
<?php the_title(); ?>
</a>
</div>
</div>
<?php endwhile; ?>
<?php else : ?>
<?php endif; ?>
但是,当我在不同的类别增加了几个电话,所有电话的一类往里走。
我真的很困惑。请帮我:(
在后端侧下一个分类全部转到 – Coder
请您解释一下更好,我可以帮你 – Coder
你能解释一下你所说的“添加了几个电话在不同的类别”和“所有手机的往里走的意思到底是什么在一个类别中“? –