2013-06-27 27 views
0

合作开发者在WordPress管理区的管理部分创建了自定义表单。我正试图让它显示在管理部分的其他地方。我认为get_option()将允许我通过名称来调用它,但它不会返回值,也不知道如何调用。从WordPress数据库获取自定义值

这里是他创建的部分,所以我想我可以使用get_option('contact_person_address')。

$wp_customize->add_control(new WP_Customize_Control($wp_customize, 'contact_person_address', array(
      'label'  => __('Site Contact Room Number & Building', 'coe'), 
      'section' => 'contact_person', 
      'settings' => 'contact_person_address', 
     ))); 

$wp_customize->add_setting('contact_person_address' , array(
       'default'  => '', 
       'transport' => 'postMessage', 
      )); 

它只是返回我分配给功能的默认设置。

+0

当然,你想要[get_setting()](https://codex.wordpress.org/Class_Reference/WP_Customize_Manager/get_setting),而不是get_option() – Anigel

+0

get_setting()函数被折旧,他们建议使用get_option()http://codex.wordpress.org/Function_Reference/get_settings –

+0

这里是答案:get_theme_mod() –

回答

0

您使用get_theme_mod()来获取自定义字段的值

相关问题