WP_Rewrite::add_endpoint
Adds an endpoint, like /trackback/.
Method of the class: WP_Rewrite{}
No Hooks.
Returns
null. Nothing (null).
Usage
global $wp_rewrite; $wp_rewrite->add_endpoint( $name, $places, $query_var );
- $name(string) (required)
- Name of the endpoint.
- $places(int) (required)
- Endpoint mask describing the places the endpoint should be added. Accepts a mask of:
EP_ALLEP_NONEEP_ALL_ARCHIVESEP_ATTACHMENTEP_AUTHORSEP_CATEGORIESEP_COMMENTSEP_DATEEP_DAYEP_MONTHEP_PAGESEP_PERMALINKEP_ROOTEP_SEARCHEP_TAGSEP_YEAR.
- $query_var(string|true|false)
- Name of the corresponding query variable. Pass
falseto skip registering a query_var for this endpoint.
Default: value of$name
Notes
- See: add_rewrite_endpoint() for full documentation.
- Global. WP.
$wpCurrent WordPress environment instance.
Changelog
| Since 2.1.0 | Introduced. |
| Since 3.9.0 | $query_var parameter added. |
| Since 4.3.0 | Added support for skipping query var registration by passing false to $query_var. |
WP_Rewrite::add_endpoint() WP Rewrite::add endpoint code WP 7.0
public function add_endpoint( $name, $places, $query_var = true ) {
global $wp;
// For backward compatibility, if null has explicitly been passed as `$query_var`, assume `true`.
if ( true === $query_var || null === $query_var ) {
$query_var = $name;
}
$this->endpoints[] = array( $places, $name, $query_var );
if ( $query_var ) {
$wp->add_query_var( $query_var );
}
}