过去几天我一直在学习Wordpress,但我在自定义帖子类型方面遇到了问题。
我已注册的帖子类型如下:
function create_kitchen_type() {
$kitchen_args = array(
\'labels\' => array(
\'name\' => __( \'Kitchens\' ),
\'singular_name\' => __( \'Kitchens\' )
),
\'public\' => true,
\'has_archive\' => true,
\'description\' => \'Kitchen custom post type description\',
\'supports\' => array(
\'title\',
\'editor\',
\'comments\'
),
\'taxonomies\' => array(\'category\'),
\'rewrite\' => array(
\'pages\' => false
)
);
register_post_type( \'kitchen_post\', $kitchen_args );
};
add_action( \'init\', \'create_kitchen_type\' );
在索引中。php输出的post类型(目前只有一种)如下所示:
$custom_post_args = array(
\'_builtin\' => false,
\'public\' => true
);
$post_types = get_post_types( $custom_post_args, \'objects\' );
foreach ( $post_types as $post_type ) {
echo \'<a href="\' . $post_type->name . \'">\' . $post_type->labels->singular_name . \'</a>\';
};
// Outputs: <a href="kitchen_post">Kitchens</a>
然后,单击链接时,地址栏显示
localhost/site_name/kitchen_post
但标题是“找不到页面”,这是我添加到archive-kitchen\\u帖子中的唯一回音。不显示php。
那么,为什么archive-kitchen\\u不是帖子呢。是否使用php?
提前谢谢。