Unable to update Woocommerce Product Permalink

Add this code to your functions.php– add_action( ‘init’, ‘the_drmatist_category_base’ ); function the_drmatist_category_base() { // Remember to flush the rules once manually after you added this code! add_rewrite_rule( // The regex to match the incoming URL ‘news/([^/]+)/([^/]+)/([^/][^f][^e][^e][^d]+)(/[0-9]+)?/?$’, //here my changes to exclude ‘feed’ // The resulting internal URL ‘index.php?product_cat=$matches[1]/$matches[2]&name=$matches[3]&paged=$matches[4]’, // Add the rule to the top … Read more

Remove custom taxonomy base from URL

Depending on how you are registering your custom post types, you can simply set the rewrite rules for it like so: $args = array( ‘description’ => ‘Photograph Post Type’, ‘label’ => __(‘Photographs’), ‘public’ => true, ‘rewrite’ => array( ‘slug’ => ‘photograph’), ); register_post_type( ‘photograph’ , $args ); If (for some bizarre reason) you don’t have … Read more

RewriteRule accepts numbers but not letters in tag

Leave .htaccess alone. You can use WordPress rewrite API for this. add_action( ‘init’, function(){ return add_rewrite_rule( ‘subdir/([^/]+)/?$’, // ([^/]+) takes alphanumeric, while ([0-9]+) accepts digits ‘index.php?pagename=subdir&website=$matches[1]’, ‘top’ ); }); add_filter(‘query_vars’, function($v){ return array_merge(array(‘website’),$v); }); First make sure subdir is a valid page slug, in this example. After you save that code to your child theme’s … Read more

Update permalinks when new category added to custom post type taxonomy

That’s not how custom taxonomies and post types work This is what you do: On the init hook, call register_custom_taxonomy or register_post_type If you change your calls to register_custom_taxonomy or register_post_type, or add new ones in your code, regenerate permalinks by visiting the permalinks settings page and clicking save You’re done So if I follow … Read more

How can I update the permalink everywhere for a custom post type?

This line: $post_link = str_replace( “https://wordpress.stackexchange.com/” . $post->post_type . “https://wordpress.stackexchange.com/”, “https://wordpress.stackexchange.com/”, $post_link ); isn’t doing what you expect because your post slug isn’t $post->post_type, it’s sp, as set here: $rewrite = array( ‘slug’ => ‘sp’, ‘with_front’ => false, ‘pages’ => true, ‘feeds’ => true, );