我正在尝试创建一个带有存档的自定义帖子类型“Press”。我想我已经完成了所需的一切,但当我转到/按url时,没有显示任何帖子。我在存档媒体中输入了“test”。php,但也没有显示,所以我假设归档php文件没有连接到新闻页面。
在我的功能中。php:
add_action( \'init\', \'create_post_type\' );
function create_post_type(){
register_post_type( \'press\',
array(
\'labels\' => array(
\'name\' => __(\'Press\'),
\'singular_name\' => __(\'Press Item\'),
\'add_new\' => __(\'Add New\'),
\'add_new_item\' => __(\'Add New Item\'),
\'edit_item\' => __(\'Edit Item\'),
\'new_item\' => __(\'New Item\'),
\'all_items\' => __(\'All Items\'),
\'view_item\' => __(\'View Items\'),
\'search_items\' => __(\'Search Press\'),
\'not_found\' => __(\'No Items found\'),
\'not_found_in_trash\' => __(\'No Items Found in Trash\'),
\'parent_item_colon\' => \'\',
\'menu_name\' => \'Press\'
),
\'labels\' => $press_labels,
\'publicly_queryable\' => true,
\'public\' => true,
\'show_ui\' => true,
\'rewrite\' => true,
\'capability_type\' => \'post\',
\'hierarchical\' => true,
\'menu_position\' => 10,
\'query_var\' => true,
\'has_archive\' =>true,
\'supports\' => array(\'title\',\'thumbnail\',\'excerpt\')
)
);
}
我的存档新闻。php:
<?php get_header(); ?>
<?php
$wp_query = new WP_Query();
$wp_query -> query(\'post_type=press&showposts=20\');
while ($wp_query->have_posts()) : $wp_query->the_post(); ?>
<div class="press-item">
<div class="press-img"><?php the_post_thumbnail(\'medium\');?></div>
<div class="press-content">
<div class="press-title"><?php single_post_title(); ?> </div>
<div class="press-excerpt"><?php the_excerpt(); ?> </div>
</div>
</div>
<?php endwhile; ?>
<?php get_footer(); ?>
我的永久链接设置为url/%类别%/%postname%/
我会做错什么?