函数原型
add_permastruct( string $name, string $struct, array $args = array() )
函数描述
Adds a permalink structure.
是否弃用
未弃用
函数参数
-
$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.
More Arguments from WP_Rewrite::add_permastruct( … $args )
Arguments for building rewrite rules based on the permalink structure.
with_frontboolWhether the structure should be prepended withWP_Rewrite::$front.
Default true.ep_maskintThe endpoint mask defining which endpoints are added to the structure.
Accepts a mask of:EP_ALLEP_NONEEP_ALL_ARCHIVESEP_ATTACHMENTEP_AUTHORSEP_CATEGORIESEP_COMMENTSEP_DATEEP_DAYEP_MONTHEP_PAGESEP_PERMALINKEP_ROOTEP_SEARCHEP_TAGSEP_YEARDefaultEP_NONE.
pagedboolWhether archive pagination rules should be added for the structure.
Default true.feedboolWhether feed rewrite rules should be added for the structure. Default true.forcommentsboolWhether the feed rules should be a query for a comments feed. Default false.walk_dirsboolWhether the'directories'making up the structure should be walked over and rewrite rules built for each in-turn. Default true.endpointsboolWhether endpoints should be applied to the generated rules. Default true.
Default:
array()
函数返回值
无
函数位置
File: wp-includes/rewrite.php.
函数源码
function add_permastruct( $name, $struct, $args = array() ) {
global $wp_rewrite;
// Back-compat for the old parameters: $with_front and $ep_mask.
if ( ! is_array( $args ) ) {
$args = array( 'with_front' => $args );
}
if ( func_num_args() == 4 ) {
$args['ep_mask'] = func_get_arg( 3 );
}
$wp_rewrite->add_permastruct( $name, $struct, $args );
}
源码链接
变更日志
| Version | Description |
|---|---|
| 3.0.0 | Introduced. |

