gpt4 book ai didi

wordpress - 自定义帖子类型给出 404

转载 作者:行者123 更新时间:2023-12-05 08:59:14 27 4
gpt4 key购买 nike

现在我知道这已经被涵盖了很多,但我已经阅读了这里以前的修复并且没有任何运气。

基本上,我的问题自定义帖子类型会出现 404 错误。

到目前为止,我已经尝试了以下方法:

  • 将永久链接设置为默认值,然后再将其改回。
  • 在 register_post_type 之前添加 flush_rewrite_rules。
  • 我已经检查过,没有同名的页面和帖子。
  • 删除并重新创建了 htaccess 文件。
  • 添加 'rewrite' => array( 'slug' => 'question','with_front' => FALSE)
  • 创建自定义永久链接结构。

代码如下:

add_action( 'init', 'irt_questions_create' );

function irt_questions_create() {

$labels = array(
'name' => _x('Questions', 'post type general name', 'your_text_domain'),
'singular_name' => _x('Question', 'post type singular name', 'your_text_domain'),
'add_new' => _x('Add New', 'Question', 'your_text_domain'),
'add_new_item' => __('Add New Question', 'your_text_domain'),
'edit_item' => __('Edit Question', 'your_text_domain'),
'new_item' => __('New Question', 'your_text_domain'),
'all_items' => __('All Questions', 'your_text_domain'),
'view_item' => __('View Question', 'your_text_domain'),
'search_items' => __('Search Questions', 'your_text_domain'),
'not_found' => __('No Questions found', 'your_text_domain'),
'not_found_in_trash' => __('No Questions found in Trash', 'your_text_domain'),
'parent_item_colon' => '',
'menu_name' => __('Questions', 'your_text_domain')
);

$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
'rewrite' => array( 'slug' => _x( 'module', 'URL slug', 'your_text_domain' ) ),
'capability_type' => 'post',
'has_archive' => true,
'hierarchical' => true,
'menu_position' => 106,
'supports' => array( 'title', 'editor', /*'author',*/ 'thumbnail', /*'excerpt', 'comments', 'custom-fields', 'revisions',*/ 'page-attributes')
);
register_post_type('question', $args);

}

最佳答案

尝试修复此问题 3 天后,我发现它是 'hierarchical' => true 给我的错误。

一旦我删除了这行代码,然后通过将永久链接设置为默认值来刷新永久链接,然后再次将它们改回,问题就解决了。

关于wordpress - 自定义帖子类型给出 404,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16568111/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com