如何在自定义 post 中添加 wordpress 自定义部分
How to add wordpress customize section in custom post
如何创建该选项,请参阅 this image
在我的自定义主题上?
我可以使用自定义 post 制作主题,但我想制作类似于此图片的网站。
谢谢。
图中显示的项目 'Customizer Sections' 是通过定制器添加的 API。您将使用类似这样的代码来添加一个部分。 注意:您还需要添加设置和控件。
<?php
function mytheme_customize_register( $wp_customize ) {
//All our sections, settings, and controls will be added here
$wp_customize->add_section( 'mytheme_new_section_slider' , array(
'title' => __( 'Slider Settings', 'mytheme' ),
'priority' => 30,
) );
// you would also have settings and controls that are added to the section.
// if you add a section and it contains no controls it will not appear.
}
add_action( 'customize_register', 'mytheme_customize_register' );
这里有一些关于 add_section
方法的文档:https://codex.wordpress.org/Class_Reference/WP_Customize_Manager/add_section
还有一些关于整个过程的信息,包括添加设置和控件:https://codex.wordpress.org/Theme_Customization_API
如何创建该选项,请参阅 this image 在我的自定义主题上? 我可以使用自定义 post 制作主题,但我想制作类似于此图片的网站。 谢谢。
图中显示的项目 'Customizer Sections' 是通过定制器添加的 API。您将使用类似这样的代码来添加一个部分。 注意:您还需要添加设置和控件。
<?php
function mytheme_customize_register( $wp_customize ) {
//All our sections, settings, and controls will be added here
$wp_customize->add_section( 'mytheme_new_section_slider' , array(
'title' => __( 'Slider Settings', 'mytheme' ),
'priority' => 30,
) );
// you would also have settings and controls that are added to the section.
// if you add a section and it contains no controls it will not appear.
}
add_action( 'customize_register', 'mytheme_customize_register' );
这里有一些关于 add_section
方法的文档:https://codex.wordpress.org/Class_Reference/WP_Customize_Manager/add_section
还有一些关于整个过程的信息,包括添加设置和控件:https://codex.wordpress.org/Theme_Customization_API