您可以创建Custom Control for WP Customizer 并使用它
For example:
class Sub_Section_Heading_Custom_Control extends WP_Customize_Control {
//The type of control being rendered
public $type = \'sub_section_heading\';
//Render the control in the customizer
public function render_content() {
?>
<div class="sub-section-heading-control">
<?php if( !empty( $this->label ) ) { ?>
<h4 class="customize-control-title">
<?php echo esc_html( $this->label ); ?>
</h4>
<?php } ?>
</div>
<?php
}
}
添加一些CSS
.sub-section-heading-control
.customize-control-title{
text-align: center;
color: white;
background-color: saddlebrown;
padding: 10px;
}
并将其添加到Customizer中的一个部分:
$wp_customize->add_setting(\'heading_post_content\', array()); // dummy
$wp_customize->add_control( new Sub_Section_Heading_Custom_Control(
$wp_customize, \'heading_post_content\',
array(
\'label\' => __( \'Post Content\', \'your-text-domain\' ), // Set heading text here
\'section\' => \'post_single\', // set section id here
)
) );
应该是这样的:
我希望这有帮助。