Remove post type slug
-
Hi,
After update of plugin and WordPress, on staging, I have a problem with removing post type slug. Slug is “landing”.
CPT UI settings for custom post type:
Rewrite: True
Custom Rewrite Slug: empty
With Front: False.Functions:
function na_remove_slug( $post_link, $post, $leavename ) { if ( 'landing' != $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 ); 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( 'post', 'landing', 'page' ) ); } } add_action( 'pre_get_posts', 'na_parse_request' );
All works on production but on staging I get 404. Can subdomain.domain.com affect this? I don’t have any other good ide why this don’t work.
Thank you!
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Remove post type slug’ is closed to new replies.