2016-12-12 90 views
0

添加OptionTree页面很简单,下面的代码很简单,但有谁知道如何检索存储的数据?从其他OptionTree页面检索数据

/** 

*钩注册管理页面 */ ADD_ACTION( '初始化', 'register_options_pages');

/** *注册所有必需的管理页面。 */ 功能register_options_pages(){

//如果OT安装 如果(is_admin()& & function_exists( 'ot_register_settings')){

// Register the pages 
ot_register_settings( 
    array(
    array( 
     'id'    => 'custom_options', 
     'pages'   => array(
     array(
      'id'    => 'test_page', 
      'parent_slug'  => 'options-general.php', 
      'page_title'  => 'Test Page', 
      'menu_title'  => 'Test Page', 
      'capability'  => 'edit_theme_options', 
      'menu_slug'  => 'test-page', 
      'icon_url'  => null, 
      'position'  => null, 
      'updated_message' => 'Test Page updated.', 
      'reset_message' => 'Test Page reset.', 
      'button_text'  => 'Save Changes', 
      'show_buttons' => true, 
      'screen_icon'  => 'options-general', 
      'contextual_help' => null, 
      'sections'  => array(
      array(
       'id'   => 'test_section', 
       'title'  => __('Test Section', 'motif-core') 
      ) 
     ), 
      'settings'  => array(
      array(
       'id'   => 'test_section_input', 
       'label'  => 'Test Input', 
       'desc'  => 'Pretty freaking awesome!', 
       'std'   => '', 
       'type'  => 'text', 
       'section'  => 'test_section', 
       'class'  => '' 
      ) 
     ) 
     ) 
    ) 
    ) 
) 
); 

我想这在管理&只执行$ my_plugin_options = get_option('custom_options');但它只在前端显示“数组”字样?

回答

0

这是如何检索所存储的数据:

$ my_plugin_options = get_option( 'custom_options');

echo $ my_plugin_options ['test_section_input'];