remove_theme_mod

函式
remove_theme_mod ( $name )
引數
  • (string) $name Theme modification name.
    Required:
定義位置
相關方法
remove_theme_modsremove_theme_supportset_theme_mod_remove_theme_supportget_theme_mod
引入
2.1.0
棄用
-

remove_theme_mod: 這個函式用來從WordPress中刪除一個主題修改。主題修改是用來定製WordPress網站的外觀的: 這個函式需要一個引數,就是要刪除的主題修改的名稱。

從活動主題列表中刪除主題修改名稱。

如果刪除名稱的同時也刪除了所有元素,那麼整個選項將被刪除。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function remove_theme_mod( $name ) {
$mods = get_theme_mods();
if ( ! isset( $mods[ $name ] ) ) {
return;
}
unset( $mods[ $name ] );
if ( empty( $mods ) ) {
remove_theme_mods();
return;
}
$theme = get_option( 'stylesheet' );
update_option( "theme_mods_$theme", $mods );
}
function remove_theme_mod( $name ) { $mods = get_theme_mods(); if ( ! isset( $mods[ $name ] ) ) { return; } unset( $mods[ $name ] ); if ( empty( $mods ) ) { remove_theme_mods(); return; } $theme = get_option( 'stylesheet' ); update_option( "theme_mods_$theme", $mods ); }
function remove_theme_mod( $name ) {
	$mods = get_theme_mods();

	if ( ! isset( $mods[ $name ] ) ) {
		return;
	}

	unset( $mods[ $name ] );

	if ( empty( $mods ) ) {
		remove_theme_mods();
		return;
	}

	$theme = get_option( 'stylesheet' );

	update_option( "theme_mods_$theme", $mods );
}

常見問題

FAQs
檢視更多 >