add_permastruct

函式
add_permastruct ( $name, $struct, $args = array() )
引數
  • (string) $name Name for permalink structure.
    Required:
  • (string) $struct Permalink structure.
    Required:
  • (array) $args Optional. Arguments for building the rules from the permalink structure, see WP_Rewrite::add_permastruct() for full details. Default empty array.
    Required:
    Default: array()
相關
  • WP_Rewrite::add_permastruct()
定義位置
相關方法
remove_permastructadd_post_metaadd_query_argadd_term_metaadd_user_meta
引入
3.0.0
棄用
-

add_permastruct: 一個為特定文章型別新增自定義固定結構的函式。它允許開發者為自定義的文章型別定義一個URL結構,這樣他們的URL就更方便使用者使用和容易記憶。

新增一個固定結構。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
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 );
}
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 ); }
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 );
}

常見問題

FAQs
檢視更多 >