从自定义自定义字段获取数据

时间:2016-11-17 08:10:23

标签: php wordpress

我在下方设置了新字段,图片和文字有两种类型我现在如何在php文件中调用它我假设它有一个功能。 我可以访问主题上的字段>自定义并向其添加数据,但现在我想粘贴到模板上。

$wp_customize->add_section('travel_video', array(
    'priority'    => 16,
    'capability'  => 'edit_theme_options',
    'title'       => __('     - Featured Videos', 'travel-lite'),
    'description' => ''
));

$wp_customize->add_setting('travel[fpvideo]', array(
    'default'           => __('Title 1', 'travel-lite'),
    'capability'        => 'edit_theme_options',
    'sanitize_callback' => 'esc_textarea',
    'type'              => 'option'
));

$wp_customize->add_control('travel_fpvideo' , array(
    'label'      => __('Title 1', 'travel-lite'),
    'section'    => 'travel_video',
    'settings'   => 'travel[fpvideo]'
));

1 个答案:

答案 0 :(得分:0)

尝试使用此代码,您可以查找参考customizer

function mytheme_customize_register($wp_customize) {
    $wp_customize->add_section('travel_video', array(
        'priority' => 16,
        'capability' => 'edit_theme_options',
        'title' => __('     - Featured Videos', 'travel-lite'),
        'description' => ''
    ));

    $wp_customize->add_setting('travel[fpvideo]', array(
        'default' => __('Title 1', 'travel-lite'),
        'capability' => 'edit_theme_options',
        'sanitize_callback' => 'esc_textarea',
        'type' => 'option'
    ));

    $wp_customize->add_control('travel_fpvideo', array(
        'label' => __('Title 1', 'travel-lite'),
        'section' => 'travel_video',
        'settings' => 'travel[fpvideo]'
    ));
}

add_action('customize_register', 'mytheme_customize_register');