【问题标题】:WordPress CPT hierarchical set to true it turns to 404 pageWordPress CPT分层设置为true它变成404页面
【发布时间】:2016-01-06 00:21:29
【问题描述】:

我有 Custmom 帖子类型 并且有一个重写 slug,它运行良好,直到我将分层设置为 true。

分层在 wp-admin 中运行良好,但是当我在前端导航时,CPT 添加的项目转到 404 页面。

请注意,flush_rewrite_rules() 已集成,并且我多次尝试使用 wordpress 4.3.1 在设置中重新提交永久链接。

$arg = [
             'public' => true,
             'show_ui' => true,
             '_builtin' => false,
             '_edit_link' => 'post.php?post=%d',
             'capability_type' => 'post',
             'hierarchical' => false,
             'rewrite' => ['slug' => 'book', 'page-attributes'],
             'query_var' => 'book',
             'supports' => ['title', 'editor', 'thumbnail'],
             'menu_position' => 5,
             'menu_icon'=> 'dashicons-testimonial'
        ];

当我设置'hierarchical' => true, 时,它会进入 404 页面。

【问题讨论】:

    标签: php wordpress custom-post-type permalinks hierarchical


    【解决方案1】:

    您似乎将page-attributes 放入了错误的数组中。它属于支持,而不是重写!在下面的数组中,我将它移到了正确的位置。希望这会有所帮助。

    $arg = [
             'public' => true,
             'show_ui' => true,
             '_builtin' => false,
             '_edit_link' => 'post.php?post=%d',
             'capability_type' => 'post',
             'hierarchical' => true,
             'rewrite' => ['slug' => 'book'],
             'query_var' => 'book',
             'supports' => ['title', 'editor', 'thumbnail', 'page-attributes'],
             'menu_position' => 5,
             'menu_icon'=> 'dashicons-testimonial'
        ];
    

    【讨论】:

    • 哦,不...... grrrrr ............这是一个更严重的错误,永远。我花了很多时间来修复它。抱歉……谢谢。
    • @jho1086 最耗时的错误总是最简单的错误:(
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-06-10
    • 2013-05-27
    • 2020-06-30
    • 1970-01-01
    相关资源
    最近更新 更多