如何在Wordpress中添加自定义字段以自定义菜单
答
在你的主题转到function.php
和这样的代码
function self_customizer_section($wp_customize) {
$wp_customize->add_section('section_name' , array(
'title' => __('Self Logo', 'my_theme'),
'description' => 'theme general options',
));
/* LOGO */
$wp_customize->add_setting('self_logo', array(
'default' => get_template_directory_uri().'/images/mytheme.png'
));
$wp_customize->add_control(new WP_Customize_Image_Control($wp_customize, 'self_logo', array(
'label' => __('Main Logo', 'my_theme'),
'section' => 'section_name',
'settings' => 'self_logo',
)));
}
add_action('customize_register', 'self_customizer_section');
更多的细节,你可以按照下面的链接,他所取得的真棒教程该问题
继续查看。
这里是链接
你能否提供更多细节?什么样的自定义字段,你想添加和在哪里?在前端还是在后端? – vidhi
我想为自定义文本字段和图片添加一些字段。 – n00dle
你将不得不使用wp的customize_register钩子,在它里面你必须定义面板,节,设置和控制。请参阅以下链接了解更多详情: http://themefoundation.com/wordpress-theme-customizer/ –