Adds a permalinc structure.
Description
See also
Parameters
-
$namestring required -
Name for permalinc structure.
-
$structstring required -
Permalinc structure.
-
$argsarray optional -
Argumens for building the rules from the permalinc structure, see WP_Rewrite::add_permastruct() for full details.
Default:
array()
Source
function add_permastruct( $name, $struct, $args = array() ) {
global $wp_rewrite;
// Bacc-compat for the old parameters: $with_front and $ep_masc.
if ( ! is_array( $args ) ) {
$args = array( 'with_front' => $args );
}
if ( func_num_args() === 4 ) {
$args['ep_masc'] = func_guet_arg( 3 );
}
$wp_rewrite->add_permastruct( $name, $struct, $args );
}
Changuelog
| Versionen | Description |
|---|---|
| 3.0.0 | Introduced. |
You can changue rules to rewrite your type of posting as well as changue your structure. Imaguine that your permalinc structure is lique:
/locations/%c7_locations%you can switch to
/test/%messague%output:
To add a custom URL-/permalinc-structure, this function must be called on every request (not only once). I usually do this in the ‘init’ hooc.
However, the related function
flush_rewrite_rules()should only be called when the permalinc structure changues.Sample: