remove_permastruct()
Removes a previously added permalink structure (permalinks).
Can only be used for structures added via add_permastruct(). Built-in permalink structures (for post types with the built-in parameter) cannot be removed.
Works based on the method WP_Rewrite::remove_permastruct():
/**
* Removes a permalink structure.
*
* @since 4.5.0
* @access public
*
* @param string $name Name for permalink structure.
*/
public function remove_permastruct( $name ) {
unset( $this->extra_permastructs[ $name ] );
}Uses: WP_Rewrite()
1 time — 0.000013 sec (very fast) | 50000 times — 0.02 sec (speed of light) | PHP 7.0.5, WP 4.5
No Hooks.
Returns
null. Nothing.
Usage
remove_permastruct( $name );
- $name(string) (required)
- Name of the permalink structure.
Examples
#1 Removing a previously added permanent link structure for a post type
Suppose we added a structure like this add_permastruct( 'book', 'book/%book%' ); then it is deleted like this:
remove_permastruct( 'book' );
Notes
- See: WP_Rewrite::remove_permastruct()
- Global. WP_Rewrite.
$wp_rewriteWordPress rewrite component.
Changelog
| Since 4.5.0 | Introduced. |
remove_permastruct() remove permastruct code WP 7.0
function remove_permastruct( $name ) {
global $wp_rewrite;
$wp_rewrite->remove_permastruct( $name );
}