Retrieves the rewrite rules.

Description Description

The difference between this method and WP_Rewrite::rewrite_rules() is that this method stores the rewrite rules in the ‘rewrite_rules’ option and retrieves it. This prevents having to process all of the permalinks to get the rewrite rules in the form of caching.

Return Return

(array) Rewrite rules.

Top ↑

Source Source

File: wp-includes/class-wp-rewrite.php

	public function wp_rewrite_rules() {
		$this->rules = get_option('rewrite_rules');
		if ( empty($this->rules) ) {
			$this->matches = 'matches';
			if ( ! did_action( 'wp_loaded' ) ) {
				add_action( 'wp_loaded', array( $this, 'flush_rules' ) );
				return $this->rules;
			update_option('rewrite_rules', $this->rules);

		return $this->rules;

Top ↑

Changelog Changelog

Version Description
1.5.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.