[ Index ]

PHP Cross Reference of WordPress




/wp-includes/ -> rewrite.php (summary)

WordPress Rewrite API

File Size: 641 lines (19 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 11 functions


Functions that are not part of a class:

add_rewrite_rule( $regex, $query, $after = 'bottom' )   X-Ref
Adds a rewrite rule that transforms a URL structure to a set of query vars.

Any value in the $after parameter that isn't 'bottom' will result in the rule
being placed at the top of the rewrite rules.

param: string       $regex Regular expression to match request against.
param: string|array $query The corresponding query vars for this rewrite rule.
param: string       $after Optional. Priority of the new rule. Accepts 'top'
since: 2.1.0
since: 4.4.0 Array support was added to the `$query` parameter.

add_rewrite_tag( $tag, $regex, $query = '' )   X-Ref
Add a new rewrite tag (like %postname%).

The `$query` parameter is optional. If it is omitted you must ensure that you call
this on, or before, the {@see 'init'} hook. This is because `$query` defaults to
`$tag=`, and for this to work a new query var has to be added.

param: string $tag   Name of the new rewrite tag.
param: string $regex Regular expression to substitute the tag for in rewrite rules.
param: string $query Optional. String to append to the rewritten query. Must end in '='. Default empty.
since: 2.1.0

remove_rewrite_tag( $tag )   X-Ref
Removes an existing rewrite tag (like %postname%).

param: string $tag Name of the rewrite tag.
since: 4.5.0

add_permastruct( $name, $struct, $args = array()   X-Ref
Add permalink structure.

param: string $name   Name for permalink structure.
param: string $struct Permalink structure.
param: array  $args   Optional. Arguments for building the rules from the permalink structure,
since: 3.0.0

remove_permastruct( $name )   X-Ref
Removes a permalink structure.

Can only be used to remove permastructs that were added using add_permastruct().
Built-in permastructs cannot be removed.

param: string $name Name for permalink structure.
since: 4.5.0

add_feed( $feedname, $function )   X-Ref
Add a new feed type like /atom1/.

param: string   $feedname Feed name.
param: callable $function Callback to run on feed display.
return: string Feed action name.
since: 2.1.0

flush_rewrite_rules( $hard = true )   X-Ref
Remove rewrite rules and then recreate rewrite rules.

param: bool $hard Whether to update .htaccess (hard flush) or just update
since: 3.0.0

add_rewrite_endpoint( $name, $places, $query_var = true )   X-Ref
Add an endpoint, like /trackback/.

Adding an endpoint creates extra rewrite rules for each of the matching
places specified by the provided bitmask. For example:

add_rewrite_endpoint( 'json', EP_PERMALINK | EP_PAGES );

will add a new rewrite rule ending with "json(/(.*))?/?$" for every permastruct
that describes a permalink (post) or page. This is rewritten to "json=$match"
where $match is the part of the URL matched by the endpoint regex (e.g. "foo" in

A new query var with the same name as the endpoint will also be created.

When specifying $places ensure that you are using the EP_* constants (or a
combination of them using the bitwise OR operator) as their values are not
guaranteed to remain static (especially `EP_ALL`).

Be sure to flush the rewrite rules - see flush_rewrite_rules() - when your plugin gets
activated and deactivated.

param: string      $name      Name of the endpoint.
param: int         $places    Endpoint mask describing the places the endpoint should be added.
param: string|bool $query_var Name of the corresponding query variable. Pass `false` to skip registering a query_var
since: 2.1.0
since: 4.3.0 Added support for skipping query var registration by passing `false` to `$query_var`.

_wp_filter_taxonomy_base( $base )   X-Ref
Filters the URL base for taxonomies.

To remove any manually prepended /index.php/.

param: string $base The taxonomy base that we're going to filter
return: string
since: 2.6.0

wp_resolve_numeric_slug_conflicts( $query_vars = array()   X-Ref
Resolve numeric slugs that collide with date permalinks.

Permalinks of posts with numeric slugs can sometimes look to WP_Query::parse_query()
like a date archive, as when your permalink structure is `/%year%/%postname%/` and
a post with post_name '05' has the URL `/2015/05/`.

This function detects conflicts of this type and resolves them in favor of the
post permalink.

Note that, since 4.3.0, wp_unique_post_slug() prevents the creation of post slugs
that would result in a date archive conflict. The resolution performed in this
function is primarily for legacy content, as well as cases when the admin has changed
the site's permalink structure in a way that introduces URL conflicts.

param: array $query_vars Optional. Query variables for setting up the loop, as determined in
return: array Returns the original array of query vars, with date/post conflicts resolved.
since: 4.3.0

url_to_postid( $url )   X-Ref
Examine a URL and try to determine the post ID it represents.

Checks are supposedly from the hosted site blog.

param: string $url Permalink to check.
return: int Post ID, or 0 on failure.
since: 1.0.0

Generated: Sat Jan 23 01:00:05 2021 Cross-referenced by PHPXref 0.7.1