WordPress ウェブサイトに 2 つの新しいサイドバーを追加しようとしています。1つは左側に、もう 1 つは右側にあり、メイン コンテンツは中央になります。レイアウトを 3 列にします。
Ready!を使用しています。Ready!でテーマに!E コマース プラグイン、ほとんどの変更を加えた子も作成しました。
問題は、サイドバーが Web サイト自体に表示されないことです。また、外観メニューのウィジェットエリアを表示すると、追加したウィジェットエリアが登録しても表示されません。
これは、 front-page.phpに挿入したコードです。
<?php get_sidebar('left'); ?>
<?php get_sidebar('right'); ?>
次に、2 つの sidebar.php ファイルの作成に進みました。
次のコードを持つsidebar-left.php
<?php
/**
* The Sidebar containing the main widget areas.
*
* @package Ready_ecommerce
* @since Ready_ecommerce 0.1
*/
?>
<div id="secondary" class="widget-area sidebar" role="complementary">
<?php do_action( 'before_sidebar' ); ?>
<?php if ( ! dynamic_sidebar( 'sidebar-6' ) ) : ?>
<aside id="search" class="widget widget_search">
<?php get_search_form(); ?>
</aside>
<aside id="archives" class="widget">
<h1 class="widget-title"><?php _e( 'Archives', 'ready_ecommerce' ); ?></h1>
<ul>
<?php wp_get_archives( array( 'type' => 'monthly' ) ); ?>
</ul>
</aside>
<aside id="meta" class="widget">
<h1 class="widget-title"><?php _e( 'Meta', 'ready_ecommerce' ); ?></h1>
<ul>
<?php wp_register(); ?>
<aside><?php wp_loginout(); ?></aside>
<?php wp_meta(); ?>
</ul>
</aside>
<?php endif; // end sidebar widget area ?>
</div><!-- #secondary .widget-area -->
<style type="text/css">
#content {
float: left;
}
</style>
sidebar-right.phpとコード:
<?php
/**
* The Sidebar containing the main widget areas.
*
* @package Ready_ecommerce
* @since Ready_ecommerce 0.1
*/
?>
<div id="secondary-2" class="widget-area sidebar" role="complementary">
<?php do_action( 'before_sidebar' ); ?>
<?php if ( ! dynamic_sidebar( 'sidebar-5' ) ) : ?>
<aside id="search" class="widget widget_search">
<?php get_search_form(); ?>
</aside>
<aside id="archives" class="widget">
<h1 class="widget-title"><?php _e( 'Archives', 'ready_ecommerce' ); ?></h1>
<ul>
<?php wp_get_archives( array( 'type' => 'monthly' ) ); ?>
</ul>
</aside>
<aside id="meta" class="widget">
<h1 class="widget-title"><?php _e( 'Meta', 'ready_ecommerce' ); ?></h1>
<ul>
<?php wp_register(); ?>
<aside><?php wp_loginout(); ?></aside>
<?php wp_meta(); ?>
</ul>
</aside>
<?php endif; // end sidebar widget area ?>
</div><!-- #secondary .widget-area -->
<style type="text/css">
#content {
float: right;
width: 759px;
}
</style>
そして最後に、次の行をfunctions.phpに追加しました
register_sidebar( array(
'name' => __( 'Content Pages Right', 'ready_ecommerce' ),
'id' => 'sidebar-5',
'description' => __( 'Right sidebar area for content pages only. Not availabe at products or catalogue pages', 'ready_ecommerce' ),
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => "</aside>",
'before_title' => '<h2 class="widget-title">',
'after_title' => '</h2>',
) );
register_sidebar( array(
'name' => __( 'Content Pages Left', 'ready_ecommerce' ),
'id' => 'sidebar-6',
'description' => __( 'Left sidebar area for content pages only. Not availabe at products or catalogue pages', 'ready_ecommerce' ),
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => "</aside>",
'before_title' => '<h2 class="widget-title">',
'after_title' => '</h2>',
) );