Wordpress删除一个帖子的帖子类型基础

时间:2016-05-19 17:36:53

标签: php wordpress

我试图删除一个所选帖子的帖子类型库。现在我得到了:

function na_remove_slug( $post_link, $post, $leavename ) {

if ( 'oferta' != $post->post_type && $post->ID != '42') {
    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 );

function na_parse_request( $query ) {

if ( ! $query->is_main_query() || 2 != count( $query->query ) || ! isset( $query->query['page'] ) ) {
    return;
}

if ( ! empty( $query->query['name'] ) ) {
    $query->set( 'post_type', array( 'oferta' ) );
}
}
add_action( 'pre_get_posts', 'na_parse_request' );

我的链接已从http://example.com/cat/single-post更改为http://example.com/single-post,但我遇到了404错误。任何想法如何解决它?

0 个答案:

没有答案