add_permastruct() wordpress function and usage This text is not used because the data attribute has a value

add_permastruct() wordpress function and usage

Home / WordPress / WordPress Wiki / add_permastruct() wordpress function and usage

add_permastruct( string $name, string $struct, array $args = array() )
Add permalink structure.

Description

See also

  • WP_Rewrite::add_permastruct()

Parameters

$name

(string) (Required) Name for permalink structure.

$struct

(string) (Required) Permalink structure.

$args

(array) (Optional) Arguments for building the rules from the permalink structure, see WP_Rewrite::add_permastruct() for full details.

Default value: array()

Sample Usage

You can change rules to rewrite your type of posting as well as change your structure. Imagine that your permalink structure is like:
/locations/%k7_locations%

you can switch to

/test/%message%

global $wp_rewrite;
$args = array(
    'with_front' => true,
    'ep_mask' => 3,
    'paged' => 1,
    'feed' => 1,
    'forcomments' => 0,
    'walk_dirs' => 1,
    'endpoints' => 1
);
add_permastruct( 'locations', 'test/%message/', $args);

output:

Array
(
    [with_front] => 1
    [ep_mask] => 3
    [paged] => 1
    [feed] => 1
    [forcomments] => 0
    [walk_dirs] => 1
    [endpoints] => 1
    [struct] => /test/%message/%
)

 

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments