我在 WordPress 中创建了一个名为“分类”的自定义帖子类型,并添加了一些帖子。
我可以看到下面的帖子/classifieds/post-title
但是,我正在尝试从中检索所有帖子,/classifieds
但出现 404 错误。
我已按照此处的说明进行操作:
http://codex.wordpress.org/Custom_Post_Types
我使用该链接中提供的以下代码创建了一个分类页面.php:
$loop = new WP_Query( array( 'post_type' => 'classified', 'posts_per_page' => 10 ) );
while ( $loop->have_posts() ) : $loop->the_post();
the_title();
echo '<div class="entry-content">';
the_content();
echo '</div>';
endwhile;
但是,如果我这样写:
$loop = new WP_Query( array( 'posts_per_page' => 10 ) );
while ( $loop->have_posts() ) : $loop->the_post();
the_title();
echo '<div class="entry-content">';
the_content();
echo '</div>';
endwhile;
它确实显示了最新的 10 个帖子。我现在确定这一定与帖子类型本身有关。
为了确保,我已经完成了整个示例,就像这里一样:
http://codex.wordpress.org/Custom_Post_Types
即使是相同的名称,我也无法进行查询,它没有显示任何结果。
我真的很沮丧。