【问题标题】:How to add wordpress customize section in custom post如何在自定义帖子中添加 wordpress 自定义部分
【发布时间】:2018-04-10 15:40:32
【问题描述】:

如何创建该选项,请参阅this image 在我的自定义主题上? 我可以使用自定义帖子制作主题,但我想制作类似于此图像的网站。 谢谢。

【问题讨论】:

    标签: wordpress wordpress-theming custom-wordpress-pages wordpress-rest-api


    【解决方案1】:

    图片中显示的项目是“定制器部分”,是通过定制器 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

    【讨论】:

      猜你喜欢
      • 2016-12-29
      • 2014-04-23
      • 2018-02-23
      • 2013-08-04
      • 1970-01-01
      • 2014-11-02
      • 2017-01-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多