我不知道为什么我的自定义帖子类型会显示找不到的页面。这是我用来注册自定义帖子的代码。
www.example.com/products/product1/
渲染404,其中为www.example.com/?products=product1
非常好。
add_action( \'init\', \'create_post_type\' );
function create_post_type() {
register_post_type(\'products\', array(
\'label\' => __(\'Products\'),
\'singular_label\' => __(\'Product\'),
\'public\' => true,
\'show_ui\' => true, // UI in admin panel
\'_builtin\' => false, // It\'s a custom post type, not built in!
\'_edit_link\' => \'post.php?post=%d\',
\'capability_type\' => \'post\',
\'hierarchical\' => false,
\'rewrite\' => array("slug" => "products"), // Permalinks format
\'supports\' => array(\'title\',\'author\')
));
}