wppaste
WordPress

WP_Rewrite

Since
1.5.0
Source
wp-includes/class-wp-rewrite.php:25
Core class used to implement a rewrite component API.

Description

The WordPress Rewrite class writes the rewrite module rules to the .htaccess file. It also handles parsing the request to get the correct setup for the WordPress Query class.

The Rewrite along with WP class function as a front controller for WordPress.
You can add rules to trigger your page view and processing using this component. The full functionality of a front controller does not exist, meaning you can't define how the template files load based on the rewrite rules.

Compatibility

WordPress
since 1.5.0
  • 6.7.7
  • 6.8.8
  • 6.9.7
  • 7.0.4
  • 7.1.0

Present in every tracked release (6.7.7 to 7.1.0).

Hooks and filters fired · 16

Every hook that fires from inside WP_Rewrite, in the order it appears in the class, grouped by the method that fires it.

Properties · 30

$use_trailing_slashesboolpublic
Whether to add trailing slashes.
$author_basestringpublic
Base for the author permalink structure (example.com/$author_base/authorname).
$author_structurestringpublic
Permalink structure for author archives.
$date_structurestringpublic
Permalink structure for date archives.
$page_structurestringpublic
Permalink structure for pages.
$search_basestringpublic
Base of the search permalink structure (example.com/$search_base/query).
$search_structurestringpublic
Permalink structure for searches.
$comments_basestringpublic
Comments permalink base.
$pagination_basestringpublic
Pagination permalink base.
$comments_pagination_basestringpublic
Comments pagination permalink base.
$feed_basestringpublic
Feed permalink base.
$comment_feed_structurestringpublic
Comments feed permalink structure.
$feed_structurestringpublic
Feed request permalink structure.
$frontstringpublic
The static portion of the post permalink structure.
$rootstringpublic
The prefix for all permalink structures.
$indexstringpublic
The name of the index file which is the entry point to all requests.
$matchesstringpublic
Variable name to use for regex matches in the rewritten query.
$rulesstring[]public
Rewrite rules to match against the request to find the redirect or query.
$extra_rulesstring[]public
Additional rules added external to the rewrite class.
$extra_rules_topstring[]public
Additional rules that belong at the beginning to match first.
$non_wp_rulesstring[]public
Rules that don't redirect to WordPress' index.php.
$extra_permastructsarray[]public
Extra permalink structures, e.g. categories, added by add_permastruct().
$endpointsarray[]public
Endpoints (like /trackback/) added by add_rewrite_endpoint().
$use_verbose_rulesboolpublic
Whether to write every mod_rewrite rule for WordPress into the .htaccess file.
$use_verbose_page_rulesboolpublic
Could post permalinks be confused with those of pages?
$rewritecodestring[]public
Rewrite tags that can be used in permalink structures.
$rewritereplacestring[]public
Regular expressions to be substituted into rewrite rules in place of rewrite tags, see WP_Rewrite::$rewritecode.
$queryreplacestring[]public
Query variables that rewrite tags map to, see WP_Rewrite::$rewritecode.
$feedsstring[]public
Supported default feeds.

Methods · 38

Source code

#[AllowDynamicProperties]class WP_Rewrite {	/**	 * Permalink structure for posts.	 *	 * @since 1.5.0	 * @var string	 */	public $permalink_structure; 	/**	 * Whether to add trailing slashes.	 *	 * @since 2.2.0	 * @var bool	 */	public $use_trailing_slashes; 	/**	 * Base for the author permalink structure (example.com/$author_base/authorname).	 *	 * @since 1.5.0	 * @var string	 */	public $author_base = 'author'; 	/**	 * Permalink structure for author archives.	 *	 * @since 1.5.0	 * @var string	 */	public $author_structure; 	/**	 * Permalink structure for date archives.	 *	 * @since 1.5.0	 * @var string	 */	public $date_structure; 	/**	 * Permalink structure for pages.	 *	 * @since 1.5.0	 * @var string	 */	public $page_structure; 	/**	 * Base of the search permalink structure (example.com/$search_base/query).	 *	 * @since 1.5.0	 * @var string	 */	public $search_base = 'search'; 	/**	 * Permalink structure for searches.	 *	 * @since 1.5.0	 * @var string	 */	public $search_structure; 	/**	 * Comments permalink base.	 *	 * @since 1.5.0	 * @var string	 */	public $comments_base = 'comments'; 	/**	 * Pagination permalink base.	 *	 * @since 3.1.0	 * @var string	 */

Changelog

Introduced in 1.5.0. Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

About this page

Parsed data
Generated from the wordpress-develop 6.9.7 tag, from src/wp-includes/class-wp-rewrite.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.