php 添加Wordpress页脚小部件区域

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php 添加Wordpress页脚小部件区域相关的知识,希望对你有一定的参考价值。

#footer-sidebar {
    display:block;
    width:100%;
    margin-left:13rem;
}

#footer-sidebar1 {
    float: left;
    width: 25%;
}

#footer-sidebar2 {
    float: left;
    width: 10%;
}

#footer-sidebar3 {
    float: left;
    width: 15%;
}

#footer-sidebar4 {
     width: 20%;
     float: left;
 }
 
#footer-sidebar5 {
    width: 25%;
    float: left;
}
<div id="footer-sidebar" class="secondary">
    <div id="footer-sidebar1">
        <?php
        if(is_active_sidebar('footer-sidebar-1')){
            dynamic_sidebar('footer-sidebar-1');
        }
        ?>
    </div>
    <div id="footer-sidebar2">
        <?php
        if(is_active_sidebar('footer-sidebar-2')){
            dynamic_sidebar('footer-sidebar-2');
        }
        ?>
    </div>
    <div id="footer-sidebar3">
        <?php
        if(is_active_sidebar('footer-sidebar-3')){
            dynamic_sidebar('footer-sidebar-3');
        }
        ?>
    </div>
    <div id="footer-sidebar4">
        <?php
        if(is_active_sidebar('footer-sidebar-4')){
            dynamic_sidebar('footer-sidebar-4');
        }
        ?>
    </div>
    <div id="footer-sidebar5">
        <?php
        if(is_active_sidebar('footer-sidebar-5')){
            dynamic_sidebar('footer-sidebar-5');
        }
        ?>
    </div>
</div>
function footer_widgets_init() {
	register_sidebar( array(
		'name'          => esc_html__( 'Sidebar', 'template-name' ),
		'id'            => 'sidebar-1',
		'description'   => esc_html__( 'Add widgets here.', 'template-name' ),
		'before_widget' => '<section id="%1$s" class="widget %2$s">',
		'after_widget'  => '</section>',
		'before_title'  => '<h2 class="widget-title">',
		'after_title'   => '</h2>',
	) );

    register_sidebar( array(
        'name' => 'Footer Sidebar 1',
        'id' => 'footer-sidebar-1',
        'description' => 'Appears in the footer area',
        'before_widget' => '<aside id="%1$s" class="widget %2$s">',
        'after_widget' => '</aside>',
        'before_title' => '<h3 class="widget-title">',
        'after_title' => '</h3>',
    ) );
    register_sidebar( array(
        'name' => 'Footer Sidebar 2',
        'id' => 'footer-sidebar-2',
        'description' => 'Appears in the footer area',
        'before_widget' => '<aside id="%1$s" class="widget %2$s">',
        'after_widget' => '</aside>',
        'before_title' => '<h3 class="widget-title">',
        'after_title' => '</h3>',
    ) );
    register_sidebar( array(
        'name' => 'Footer Sidebar 3',
        'id' => 'footer-sidebar-3',
        'description' => 'Appears in the footer area',
        'before_widget' => '<aside id="%1$s" class="widget %2$s">',
        'after_widget' => '</aside>',
        'before_title' => '<h3 class="widget-title">',
        'after_title' => '</h3>',
    ) );
    register_sidebar( array(
        'name' => 'Footer Sidebar 4',
        'id' => 'footer-sidebar-4',
        'description' => 'Appears in the footer area',
        'before_widget' => '<aside id="%1$s" class="widget %2$s">',
        'after_widget' => '</aside>',
        'before_title' => '<h3 class="widget-title">',
        'after_title' => '</h3>',
    ) );
    register_sidebar( array(
        'name' => 'Footer Sidebar 5',
        'id' => 'footer-sidebar-5',
        'description' => 'Appears in the footer area',
        'before_widget' => '<aside id="%1$s" class="widget %2$s">',
        'after_widget' => '</aside>',
        'before_title' => '<h3 class="widget-title">',
        'after_title' => '</h3>',
    ) );

}
add_action( 'widgets_init', 'footer_widgets_init' );

以上是关于php 添加Wordpress页脚小部件区域的主要内容,如果未能解决你的问题,请参考以下文章

php 页脚小部件标题

php 将Genesis页脚小部件更改为4列/类

在页脚小部件中居中图像

css 更改页脚小部件的宽度

scss 使用flexblox的页脚小部件

css 关闭侧栏链接和页脚小部件中的箭头。