如何在自定义帖子类型中维护父子关系,以便有一个统一的URL结构?我想制作一个高达4级的URL结构,例如。
example.com/sponsor-child/disadvantaged-community/gita-magar
没有插件是否可能?当我转到单页URL时,它以3个级别结束。如何在自定义帖子类型中维护父子关系,以便有一个统一的URL结构?我想制作一个高达4级的URL结构,例如。
example.com/sponsor-child/disadvantaged-community/gita-magar
没有插件是否可能?当我转到单页URL时,它以3个级别结束。在您的register_post_type
调用,确保您有以下参数:
register_post_type(
\'my_post_type\',
array(
\'hierarchical\' => true,
\'public\' => true,
\'rewrite\' => array(
\'slug\' => \'my_post_type\',
\'with_front\' => false,
),
\'supports\' => array(
\'page-attributes\' /* This will show the post parent field */,
\'title\',
\'editor\',
\'something-else\',
),
// Other arguments
)
);
确保永久链接已刷新(只需访问设置>永久链接页面)。现在,当您创建新my_post_type
, 只需将其父级设置为另一个,它的永久链接将如下所示:
http://example.com/parent-post-type/my-post-type/
你可以根据需要进行任意级别的练习。