B-219 Sec-55 Noida, India
+918010221733

Change Slug of a Plugin’s Custom Post Type in Wordpress

Update woocommerce cart without refreshing the page via Ajax.

Let me tell you how you can do so.

For example you have have a plugin X which have created a taxonomy with slug “locations” and you want to change it to “neighborhoods”.

Use the below given code for making this work.

<?php

function add_custom_rewrite_rule_for_taxonomy() {
// the default permalink structure is being used.
if( ($current_rules = get_option(‘rewrite_rules’)) ) {
foreach($current_rules as $key => $val) {
if(strpos($key, ‘locations’) !== false) {
add_rewrite_rule(str_ireplace(‘locations’, ‘neighborhoods’, $key), $val, ‘top’);
} // end if
} // end foreach

} // end if/else

//  flush the rewrite rules
flush_rewrite_rules();

}
add_action(‘init’, ‘add_custom_rewrite_rule_for_taxonomy’);

?>


Paste this code in your theme’s functions.php and make the necessary changes.

Please don’t forget to refresh the permalinks after making the changes.

(Visited 46 times, 1 visits today)

Leave a reply


Positioning Roulette
Positioning Roulette
UmbiliCAD Software
UmbiliCAD Software
Bethesda Real Estate Pros
Bethesda Real Estate Pros
Dark Roast Media
Dark Roast Media
HAIR & MAKE-UP BY JOHN O
HAIR & MAKE-UP BY JOHN O
Metropolitan & Waterfront Residential Brokerage
Metropolitan & Waterfront Residential Brokerage
Concierge Redefined
Concierge Redefined
The Interiors Group
The Interiors Group
The Divine Artisans
The Divine Artisans