我目前正在尝试创建自己的主题,但我不太确定get\\u option()函数是如何工作的,因为这是为什么。。
echo get_option(\'show_header\', \'sultenhest_theme_display_options\');
echo get_option(\'sultenhest_theme_display_options\')[\'show_header\'];
。。两者都返回1(但Dreamweaver不喜欢第二个选项)。虽然echo get_option(\'twitter\', \'sultenhest_theme_social_options\');
。。只返回“sultenhest\\u theme\\u social\\u options”,这是不正确的。一个选项是这样定义数组
$social_options = get_option( \'sultenhest_theme_social_options\' );
这样称呼它echo $social_options[\'twitter\'];
它返回正确的字符串,但只在标题中起作用。php(如果在其中定义了数组)文件,而不是在中,例如页脚。php。更新:继ialocin和Brad Dalton之后,我想出了这个解决方案,它就像一个魔咒:
function sultenhest($option, $arg){
$the_array = array();
foreach( get_option(\'sultenhest_theme_\'.$option) as $key => $item ){
$the_array[$key] = $item;
}
return $the_array[$arg];
}
然后像这样回应:echo sultenhest(\'social_options\', \'twitter\') ? \'<a href="\' . sultenhest(\'social_options\', \'twitter\') . \'">Twitter</a>\' : \'\';