2016-12-12 99 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'];