Php Wordpress可以';似乎没有返回costum post类型的存档
这一整天都让我发疯,不知道我做错了什么,但也许你的一双锐利的眼睛会发现 基本上,我有一个自定义帖子类型(“eac_english”)的帖子要归档。使用WP模板层次结构指导原则,创建一个名为“archive-eac_english.php”的文档应该解决这个问题,但是当我将代码添加到这个文档中时,它不会调用定义的帖子。它只返回一个空白页 下面是我的funtion.php代码:Php Wordpress可以';似乎没有返回costum post类型的存档,php,wordpress,archive,custom-post-type,Php,Wordpress,Archive,Custom Post Type,这一整天都让我发疯,不知道我做错了什么,但也许你的一双锐利的眼睛会发现 基本上,我有一个自定义帖子类型(“eac_english”)的帖子要归档。使用WP模板层次结构指导原则,创建一个名为“archive-eac_english.php”的文档应该解决这个问题,但是当我将代码添加到这个文档中时,它不会调用定义的帖子。它只返回一个空白页 下面是我的funtion.php代码: add_action( 'init', 'create_post_type' ); function create_pos
add_action( 'init', 'create_post_type' );
function create_post_type() {
register_post_type( 'eac_english',
array(
'labels' => array(
'name' => __( 'English' ),
'singular_name' => __( 'English' )
),
'supports' => array( 'title', 'editor', 'comments', 'excerpt', 'custom-fields', 'thumbnail' ),
'taxonomies' => array('category'),
'public' => true,
'has_archive' => true,
'rewrite' => array('slug' => 'en'),
)
);
然后,在一个名为archive-eac_english.php的文档中,我有以下内容:
<?php
$the_query = new WP_Query( array(
'post_type' => 'eac_english',
'orderby' => 'date',
'category_name' => 'past-featured-artist', //name of category by slug
'order' => 'DESC',
'posts_per_page' => 12)); // how many posts to show
$x = 0;
while ( $the_query->have_posts() ) :
$the_query->the_post(); ?>
<div class="home_post_box">
<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('grid-image'); ?></a>
<a href="<?php the_permalink(); ?>" class="home_post_text"><h3><?php the_title(); ?></h3></a>
</div><!--//home_post_box-->
<?php $x++; ?>
<?php endwhile; ?>
<?php wp_reset_query(); ?>
我有一篇“eac_english”帖子,其类别定义为“过去的特写艺术家”,但当我访问该页面“url/category/past featured Artister/”时,没有返回任何内容
现在,如果我把'archive-eac_english.php'中的所有代码都添加到'archive.php'中,它就可以正常工作了,但显然这并没有让我选择只调用'eac_english'下组织的帖子
任何帮助都将不胜感激!
干杯,我刚刚意识到我把档案页面称为“archive-eac_english”,我把它改为“过去的特色艺术家类别”,一切都解决了