Rewriting a custom post type causes 404 error in other pages and post types
-
This code i have added for rewrite booking_spots slug based on category
function ns_update_booking_spot_cpt($args, $post_type){ if($post_type == 'booking_spots'){ $args['has_archive'] = true; $args['rewrite'] = array('slug' => '%sports-category%'); $args['with_front'] = false; } return $args; } add_filter('register_post_type_args', 'ns_update_booking_spot_cpt', 10, 2);
add_filter( 'get_the_archive_title_prefix', '__return_false' ); function keep_product_link( $post_link, $id = 0 ) { $post = get_post($id); $terms = wp_get_object_terms( $post->ID, 'sports-category' ); $custom_field_values = get_field( 'Location',$post->ID); $value = ""; foreach($custom_field_values as $custom_field_value ): $value = $custom_field_value; endforeach; if($custom_field_values){ return str_replace( '%sports-category%' , $value , $post_link ); } return $post_link; } add_filter( 'post_type_link', 'keep_product_link', 10, 2 );
This code fort generating post link based on category
The Single booking spot is showing properly but all other post type and pages are showing 404
https://healspots.com/playspots-wp/Coimbatore/sbm-sports-kalapatti-road-kurumbapalayam-coimbatore-2/ : loading properly
https://healspots.com/playspots-wp/playspots-about-us/:404 not found
The page I need help with: [log in to see the link]
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Rewriting a custom post type causes 404 error in other pages and post types’ is closed to new replies.