[英]How to programmatically get the theme main color in WordPress?
Is there a way that I can grab the active theme main color like get_user_option( 'admin_color' )
. 有没有一种方法可以获取活动主题的主色,例如get_user_option( 'admin_color' )
。 Otherwise what is the best way? 否则最好的方法是什么? I know theme options are stored under wp_options under like theme_mods_twentyfifteen
but is there an easier way to grab it? 我知道主题选项存储在像theme_mods_twentyfifteen
这样的theme_mods_twentyfifteen
但是有没有更简单的方法来获取它?
The get_theme_mod()
function would be the most appropriate for what you wanted. get_theme_mod()
函数最适合您的需求。 This relies on the theme actually saving a main color
option of some kind as a theme_mod (they should be, really all theme modifications should be theme_mod
s and not regular options). 这依赖于主题实际上将某种main color
选项保存为theme_mod(它们应该是,实际上所有主题修改都应该是theme_mod
而不是常规选项)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.