wordpress / latest / functions / flush_rewrite_rules.html

flush_rewrite_rules( bool $hard = true )

Removes rewrite rules and then recreate rewrite rules.

Parameters

$hard bool Optional
Whether to update .htaccess (hard flush) or just update rewrite_rules option (soft flush). Default is true (hard).

Default: true

More Information

This function is useful when used with custom post types as it allows for automatic flushing of the WordPress rewrite rules (usually needs to be done manually for new custom post types). However, this is an expensive operation so it should only be used when necessary.

Source

File: wp-includes/rewrite.php. View all references

function flush_rewrite_rules( $hard = true ) {
	global $wp_rewrite;

	if ( is_callable( array( $wp_rewrite, 'flush_rules' ) ) ) {
		$wp_rewrite->flush_rules( $hard );
	}
}

Uses

Uses Description

Used By

Used By Description

Changelog

Version Description
3.0.0 Introduced.

© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/flush_rewrite_rules