0
我想删除wordpress永久链接中特定自定义帖子的类别基地。我使用WP No Category Base
插件,但这是为所有人工作。删除类别基地的单个自定义帖子类型
我想删除wordpress永久链接中特定自定义帖子的类别基地。我使用WP No Category Base
插件,但这是为所有人工作。删除类别基地的单个自定义帖子类型
你可以尝试这段代码从url中删除任何自定义分类的基地。 把它放在你的functions.php或你的插件主文件中。这里
function sr_remove_cat_base($link, $term, $taxonomy)
{
// Name of your custom taxonomy (category)
if ($taxonomy !== 'custom_tax') // Don't do anything if not our cpt taxonomy
return $link;
// Slug of your custom taxonomy (category)
return str_replace('custom-tax/', '', $link); // Remove the base
}
add_filter('term_link', 'sr_remove_cat_base', 10, 3);
检查,希望它可以帮助你:http://wpgarage.com/code-snippets/remove-permalink-base-custom-post-type-slug/ –
请不要标记您的问题作为紧急的 - 详细,经过深入研究的问题应该在适当的时候获得答复。我将添加'php'标签。 – halfer
请参阅https://codex.wordpress.org/Function_Reference/register_post_type#rewrite –