Removed slug from custom post type URLs page template issues

Question

I use this function Remove slug from custom post type post URLs to remove slug from custom post type URLs .. but now I have issues… page.php is not working … so now my pages with default template use single.php instead page.php .. is there any solution to fix this? 🙁

EDIT:

I found solution on this link Remove Slug from Custom Post Type answer from user @cybmeta helps

add_action( 'parse_query', 'wpse_parse_query' );
function wpse_parse_query( $wp_query ) {

    if( get_page_by_path($wp_query->query_vars['name']) ) {
        $wp_query->is_single = false;
        $wp_query->is_page = true;
    }

}

Only issues I can found now is to Prevent duplicate post slugs .. but this is another issues 🙂

0
, , , Davor Popovic 2 years 2020-01-15T08:41:12-05:00 0 Answers 79 views 0

Leave an answer

Browse
Browse