添加多个自定义小部件无法在Wordpress中获取数据

时间:2019-01-09 08:31:08

标签: wordpress

我正在尝试将多个自定义窗口小部件添加到我的自定义模板文件中,例如将电子邮件作为一个窗口小部件,办公室地址,位置等。.并且尝试通过添加自定义窗口小部件的代码来显示仅一个窗口小部件的数据而不获取数据其他小部件。

这是我在function.php文件中添加的代码

Function.PHP

            function contactus_widgets() {
            // custom page template - before content widget area
    register_sidebar( array(
'name' => __( 'Office Location', 'singlesite' ),
'id' => 'widgetized-page-before-content-widget-area',
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h4 class="text-uppercase mb-5">',
'after_title' => '</h4>'
     ));
     register_sidebar( array(
'name' => __( 'Office Location2', 'singlesite' ),
'id' => 'office-widgetized-page-before-content-widget-area',
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h4 class="widgettitle">',
'after_title' => '</h4>'
      ));
       }
       add_action( 'widgets_init', 'contactus_widgets' );  

Template.php

           <div class="col-sm-12 col-md-6 col-lg-3 my-5">
           <div class="card border-0">
              <div class="card-body text-center">
                <i class="fa fa-map-marker fa-5x mb-3" aria-hidden="true"></i>
                <?php if( is_active_sidebar( 'widgetized-page-before-content-widget-area' ) ) : ?>
                    <aside class="widgetized-page-before-content-widget-area">
                        <?php dynamic_sidebar( 'widgetized-page-before-content-widget-area' ); ?>
                    </aside>
                <?php endif; ?>
              </div>
            </div>
         </div>
         <div class="col-sm-12 col-md-6 col-lg-3 my-5">
           <div class="card border-0">
              <div class="card-body text-center">
                <i class="fa fa-map-marker fa-5x mb-3" aria-hidden="true"></i>
               <?php if( is_active_sidebar( 'office-widgetized-page-before-content-widget-area' ) ) : ?>
                    <aside class="office-widgetized-page-before-content-widget-area">
                        <?php dynamic_sidebar( 'office-widgetized-page-before-content-widget-area' ); ?>
                    </aside>
                <?php endif; ?>

              </div>
            </div>
         </div>

0 个答案:

没有答案