WordPress at a glance
function is not described

WP_Post_Type::remove_rewrite_rules() WP 4.6.0

Removes any rewrite rules, permastructs, and rules for the post type.

This is a method of the class: WP_Post_Type

No Hooks.

Return

Null. Nothing.

Usage

$WP_Post_Type = new WP_Post_Type();
$var = $WP_Post_Type->remove_rewrite_rules();

Notes

  • Global. WP_Rewrite. $wp_rewrite WordPress rewrite component.
  • Global. WP. $wp Current WordPress environment instance.
  • Global. Array. $post_type_meta_caps Used to remove meta capabilities.

Changelog

Since 4.6.0 Introduced.

Code of WP Post Type::remove rewrite rules: wp-includes/class-wp-post-type.php WP 5.2.2

<?php
public function remove_rewrite_rules() {
	global $wp, $wp_rewrite, $post_type_meta_caps;

	// Remove query var.
	if ( false !== $this->query_var ) {
		$wp->remove_query_var( $this->query_var );
	}

	// Remove any rewrite rules, permastructs, and rules.
	if ( false !== $this->rewrite ) {
		remove_rewrite_tag( "%$this->name%" );
		remove_permastruct( $this->name );
		foreach ( $wp_rewrite->extra_rules_top as $regex => $query ) {
			if ( false !== strpos( $query, "index.php?post_type=$this->name" ) ) {
				unset( $wp_rewrite->extra_rules_top[ $regex ] );
			}
		}
	}

	// Remove registered custom meta capabilities.
	foreach ( $this->cap as $cap ) {
		unset( $post_type_meta_caps[ $cap ] );
	}
}