Title: WP_Rewrite::init
Published: April 25, 2014
Last modified: May 20, 2026

---

# WP_Rewrite::init()

## In this article

 * [Description](https://developer.wordpress.org/reference/classes/wp_rewrite/init/?output_format=md#description)
 * [More Information](https://developer.wordpress.org/reference/classes/wp_rewrite/init/?output_format=md#more-information)
 * [Source](https://developer.wordpress.org/reference/classes/wp_rewrite/init/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/classes/wp_rewrite/init/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/classes/wp_rewrite/init/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/classes/wp_rewrite/init/?output_format=md#wp--skip-link--target)

Sets up the object’s properties.

## 󠀁[Description](https://developer.wordpress.org/reference/classes/wp_rewrite/init/?output_format=md#description)󠁿

The ‘use_verbose_page_rules’ object property will be set to true if the permalink
structure begins with one of the following: ‘%postname%’, ‘%category%’, ‘%tag%’,
or ‘%author%’.

## 󠀁[More Information](https://developer.wordpress.org/reference/classes/wp_rewrite/init/?output_format=md#more-information)󠁿

Set up the object, set $permalink_structure and $category_base from the database.
Set $root to $index plus ‘/’. Set $front to everything up to the start of the first
tag in the permalink structure. Unset all other properties.

## 󠀁[Source](https://developer.wordpress.org/reference/classes/wp_rewrite/init/?output_format=md#source)󠁿

    ```php
    public function init() {
    	$this->extra_rules         = array();
    	$this->non_wp_rules        = array();
    	$this->endpoints           = array();
    	$this->permalink_structure = get_option( 'permalink_structure' );
    	$this->front               = substr( $this->permalink_structure, 0, strpos( $this->permalink_structure, '%' ) );
    	$this->root                = '';

    	if ( $this->using_index_permalinks() ) {
    		$this->root = $this->index . '/';
    	}

    	unset( $this->author_structure );
    	unset( $this->date_structure );
    	unset( $this->page_structure );
    	unset( $this->search_structure );
    	unset( $this->feed_structure );
    	unset( $this->comment_feed_structure );

    	$this->use_trailing_slashes = str_ends_with( $this->permalink_structure, '/' );

    	// Enable generic rules for pages if permalink structure doesn't begin with a wildcard.
    	if ( preg_match( '/^[^%]*%(?:postname|category|tag|author)%/', $this->permalink_structure ) ) {
    		$this->use_verbose_page_rules = true;
    	} else {
    		$this->use_verbose_page_rules = false;
    	}
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/class-wp-rewrite.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.0/src/wp-includes/class-wp-rewrite.php#L1919)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-includes/class-wp-rewrite.php#L1919-L1946)

## 󠀁[Related](https://developer.wordpress.org/reference/classes/wp_rewrite/init/?output_format=md#related)󠁿

| Uses | Description | 
| [WP_Rewrite::using_index_permalinks()](https://developer.wordpress.org/reference/classes/wp_rewrite/using_index_permalinks/)`wp-includes/class-wp-rewrite.php` |

Determines whether permalinks are being used and rewrite module is not enabled.

  | 
| [get_option()](https://developer.wordpress.org/reference/functions/get_option/)`wp-includes/option.php` |

Retrieves an option value based on an option name.

  |

| Used by | Description | 
| [wp_install_defaults()](https://developer.wordpress.org/reference/functions/wp_install_defaults/)`wp-admin/includes/upgrade.php` |

Creates the initial content for a newly-installed site.

  | 
| [WP_Rewrite::set_permalink_structure()](https://developer.wordpress.org/reference/classes/wp_rewrite/set_permalink_structure/)`wp-includes/class-wp-rewrite.php` |

Sets the main permalink structure for the site.

  | 
| [WP_Rewrite::set_category_base()](https://developer.wordpress.org/reference/classes/wp_rewrite/set_category_base/)`wp-includes/class-wp-rewrite.php` |

Sets the category base for the category permalink.

  | 
| [WP_Rewrite::set_tag_base()](https://developer.wordpress.org/reference/classes/wp_rewrite/set_tag_base/)`wp-includes/class-wp-rewrite.php` |

Sets the tag base for the tag permalink.

  | 
| [WP_Rewrite::__construct()](https://developer.wordpress.org/reference/classes/wp_rewrite/__construct/)`wp-includes/class-wp-rewrite.php` |

Constructor – Calls [init()](https://developer.wordpress.org/reference/functions/init/) , which runs setup.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/classes/wp_rewrite/init/?output_format=md#changelog)󠁿

| Version | Description | 
| [1.5.0](https://developer.wordpress.org/reference/since/1.5.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fwp_rewrite%2Finit%2F)
before being able to contribute a note or feedback.