get_theme_mod相关函数知识点

get_theme_mod()函数和get_option()函数的功能类似。

get_theme_mod()函数获取的数据来自wp_options表中的option_name字段下面“theme_mod_主题名称”对应的值,很多数据都存储在这个对应的值中,不是一条单独的数据。

一,get_option()函数获取的数据来自wp_options表中“设置好的ID”这个字段对应的值,是一条单独的数据。

get_option()函数有相关的4个函数,分别是:

get_option() 获取/查看

add_option()  添加

update_option()  修改

delete_option()  删除

 

二,get_theme_mod()获取的数据,不会以独立的数据保存到数据表中,而是作为“option_name=theme_mods_当前主题”这条数据中,一部分信息而保存起来的。

get_theme_mod()有相关的5个函数,分别是:

1,get_theme_mod()

获取/查看 数据

获取字段option_name为“theme_mod_主题名称”对应的option_value字段中ID为$name的值,如果获取不到(鸿硕测试指获取不到这条数据记录才会使用默认值,获取到数据ID对应的值为空也不会使用第2个参数的默认值)会使用第2个参数的默认值。

语法:get_theme_mod( string $name, mixed $default = false )

Parameters #Parameters
$name
(string) (Required) Theme modification name.

$default
(mixed) (Optional) Theme modification default value.

Default value: false

例:get_theme_mod('hongsweb',  'website construction')

 

2,get_theme_mods()

无需参数,获取option_name字段下面“theme_mod_主题名称”对应的option_value字段中的所有数据,为一个数组,可打印测试。

 

3,set_theme_mod()

设置或修改数据

也就是设置或修改字段option_name为“theme_mod_主题名称”对应的option_value字段中ID为$name的值为$value。

语法:set_theme_mod( string $name, mixed $value )

Parameters #Parameters
$name
(string) (Required) Theme modification name.

$value
(mixed) (Required) Theme modification value.

 

4,remove_theme_mod()

删除字段option_name为“theme_mod_主题名称”对应的option_value字段中ID为$name的值。

语法:remove_theme_mod( string $name )

Parameters #Parameters
$name
(string) (Required) Theme modification name.

 

5,remove_theme_mods()

删除字段option_name为“theme_mod_主题名称”对应的option_value字段中的所有值。

 

给TA打赏
共{{data.count}}人
人已打赏
wordpress函数

get_option()函数的相关知识点

2022-2-20 11:57:51

IT百科

微软拼音输入法输入特殊字符的方法

2021-1-24 13:49:22

0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索