Ecommerce Shopify WordPress Discussion

Rewriting a custom post type causes 404 error in other pages and post types

This code is used for rewriting url slug of a booking_spots post type 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); Run code snippetExpand snippet And for changing the post link i have used this code add_filter( 'get_the_archive_title_prefix', '__return_false' ); function keep_product_link( $post_link, $id = 0 ) { $post = get_post($id); $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 ); In this Location is acf field name and after saving permalinks The is loading properly(booking_spots post ) but all other pages and post are showing 404 For eg Please Help me to fix this issue
TurboCommerce make the better internet purchasing globaly

Turbo Multi-language Translator

Make the better internet purchasing globaly

Turbosify SEO Speed Booster

5.0 (7) Free plan available
Get better conversions by improving store loading speed Installed

Turbo Multi-language Chat - AI Customer service in one hand

TurboCommerce make the better internet purchasing globaly
Our products

The help you need, when you need it

App by Turbo Engine

3 apps • 5.0 average rating

Turbosify Speed Booster

5.0 (7)
Get better conversions by optimizing shopify store Google page speed Installed

Turbosify Translator for Wordpress Woocommerce

5.0 (74) Free Wordpress Woocommerce Plugin
Translate your wordpress website to multiple language within 1 click, no configuration needed, no No technical required

Grow your business here

Whether you want to sell products down the street or around the world, we have all the tools you need.