我有一个自定义的post类型,名为products,它的定义如下:
register_post_type(
'products',
tp_build_post_args(
'products', 'Product', 'Products',
array(
'menu_icon' => 'dashicons-cart',
'menu_position' => 20,
'has_archive' => 'products',
'public' => true,
'hierarchical' => true,
'supports' => array('editor', 'title', 'revisions', 'page-attributes'),
'rewrite' => array ( 'slug' => 'products', 'with_front' => false )
)
)
);在Pages下,我有一个名为"Products“的页面,其网址为(/products)。
在Products自定义帖子类型下,我有"Products“的所有子页面,即/products/test-page。
但是,当我转到/products时,页面被破坏了,它向我显示了一个包含Products自定义post类型下所有构建块的页面。然而,如果我转到/products-2 (只是产品页面的克隆),它工作得很好?
发布于 2019-09-04 19:45:54
这是因为您的自定义post类型插件和页面插件是相同的,即products。所以最高优先级是自定义post类型的slug。如果你想要产品,作为你的页面,所以你必须改变自定义post类型的插件。另外,更改has_archive段塞。更改后,不要忘记再次保存固定链接。
https://stackoverflow.com/questions/57783782
复制相似问题