Skip to content

Instantly share code, notes, and snippets.

@jjjjcccjjf
Created November 22, 2017 10:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jjjjcccjjf/8fc9a5ba9bcc016477f076b8fbf71610 to your computer and use it in GitHub Desktop.
Save jjjjcccjjf/8fc9a5ba9bcc016477f076b8fbf71610 to your computer and use it in GitHub Desktop.
Put in functions.php wordpress
/** remove slugggg */
function na_remove_slug( $post_link, $post, $leavename ) {
if ( 'venue_cpt' != $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', 'venue_cpt', 'page' ) );
}
}
add_action( 'pre_get_posts', 'na_parse_request' );
/** remove slug end **/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment