如何从wordpress 4.7中的网址中删除特定的自定义帖子类型slug
这是该链接 http://dmstage.com/gardencity/projects/bridge-construction/
但我需要它应该是这样的 http://dmstage.com/gardencity/bridge-construction/
projects
应该从链接中删除..我只是试图在functions.php中重写它。但是无法正确地做到这一点..
提前致谢..
答案 0 :(得分:1)
尝试创建此功能:
function na_remove_slug( $post_link, $post, $leavename ) {
if ( 'events' != $post->post_type || 'publish' != $post->post_status ) {
return $post_link;
}
$post_link = str_replace( '/' . $post->post_type . '/', '/', $post_link );
return $post_link;
}
add_filter( 'post_type_link', 'na_remove_slug', 10, 3 );