AutoFocus+のFooterに新たにWidgetエリアを追加
公開日: 2011年3月5日土曜日 No Category WordPress
フッターにウィジェットエリアを追加したいなぁ〜と思いまして。
えっと、、、デフォルトではフッターにウィジェットが4つ横並びなんですね。
↑こんな感じで。
で、その下に横全体にまたがってウィジェットエリアを新たに追加したいな、と。
↑こんな感じに。
いろいろ調べて試行錯誤しながらなんとかできたっぽいのでとりあえず備忘録的にやった作業をメモ。
- ウィジェットエリアの新規追加
調べるとどうもregister_sidebarをいじるっぽいことがわかったので
themes/autofocusplus/thematic-functions.phpの386行目付近、function childtheme_sidebars_init 内にRegister the 4th Subsidairy Sidebarをパクって5つ目を。
[php] // Register the 5th Subsidairy Sidebar
register_sidebar(array(
'name' => '5th Subsidiary Aside',
'id' => '5th-subsidiary-aside',
'description' => __('The 5th widget area in the footer.', 'thematic'),
'before_widget' => thematic_before_widget(),
'after_widget' => thematic_after_widget(),
'before_title' => thematic_before_title(),
'after_title' => thematic_after_title(),
));[/php]
続いてその下の
// Add 4th Sidebar Area
function add_fourth_sidebar() {
に5th目を追記
[php]// Add 4th Sidebar Area
function add_fourth_sidebar() {
if (is_sidebar_active('4th-subsidiary-aside')) {
echo thematic_before_widget_area('4th-subsidiary-aside');
dynamic_sidebar('4th-subsidiary-aside');
echo thematic_after_widget_area('4th-subsidiary-aside');
}
if (is_sidebar_active('5th-subsidiary-aside')) {
echo thematic_before_widget_area('5th-subsidiary-aside');
dynamic_sidebar('5th-subsidiary-aside');
echo thematic_after_widget_area('5th-subsidiary-aside');
}
}
add_action('thematic_after_third_sub','add_fourth_sidebar');[/php] - htmlを出力する箇所にも5つ目を追加
themes/thematic/library/extensions/widgets-extensions.php
[php]// this function returns the opening CSS markup for the widget area
function thematic_before_widget_area($hook) {
$content = "\n";
if ($hook == 'primary-aside') {
$content .= '<div id="primary" class="aside main-aside">' . "\n";
} elseif ($hook == 'secondary-aside') {
$content .= '<div id="secondary" class="aside main-aside">' . "\n";
} elseif ($hook == '1st-subsidiary-aside') {
$content .= '<div id="first" class="aside sub-aside">' . "\n";
} elseif ($hook == '2nd-subsidiary-aside') {
$content .= '<div id="second" class="aside sub-aside">' . "\n";
} elseif ($hook == '3rd-subsidiary-aside') {
$content .= '<div id="third" class="aside sub-aside">' . "\n";
} else {
$content .= '<div id="' . $hook . '" class="aside">' ."\n";
}
$content .= "\t" . '<ul class="xoxo">' . "\n";
return apply_filters('thematic_before_widget_area', $content);
}[/php]
↑これを↓こう
[php]// this function returns the opening CSS markup for the widget area
function thematic_before_widget_area($hook) {
$content = "\n";
if ($hook == 'primary-aside') {
$content .= '<div id="primary" class="aside main-aside">' . "\n";
} elseif ($hook == 'secondary-aside') {
$content .= '<div id="secondary" class="aside main-aside">' . "\n";
} elseif ($hook == '1st-subsidiary-aside') {
$content .= '<div id="first" class="aside sub-aside">' . "\n";
} elseif ($hook == '2nd-subsidiary-aside') {
$content .= '<div id="second" class="aside sub-aside">' . "\n";
} elseif ($hook == '3rd-subsidiary-aside') {
$content .= '<div id="third" class="aside sub-aside">' . "\n";
} elseif ($hook == '5th-subsidiary-aside') {
$content .= '<div id="' . $hook . '" class="aside5">' ."\n";
} else {
$content .= '<div id="' . $hook . '" class="aside">' ."\n";
}
$content .= "\t" . '<ul class="xoxo">' . "\n";
return apply_filters('thematic_before_widget_area', $content);
}[/php]
classをasideからaside5に変更してます。
これはウィジェットの1つ目から4つ目はfloat:leftで横に並ぶようになってたので。
5つ目もasideのままだと1つ目のウィジェットの下に、同じ幅で追加されちゃうので5つ目は横幅いっぱいに表示するスタイルを適用したいため。 - aside5のスタイルを定義
ダッシュボード > 外観 > テーマ変更 にてstyle.cssに追記します。
4つ並んだウィジェットの下に横全体にまたがった領域を5つ目として以下を追加。
[css]#subsidiary .aside5 {margin:0 auto;width:800px;}[/css]
あとは asideのスタイル をコピってきて、5つ目のWidgetに配置しそうなものを追加。
[css]/* Asides5
-------------------------------------------------------------- */
.aside5 {margin:44px 0;float:left; position:relative;}
.aside5 h3 {padding:0 8px;font-size:16px;margin:0;}
.aside5 ul {padding:0;margin:0;list-style:none;}
.aside5 ul li.widgetcontainer {margin-bottom:22px;line-height:22px;font-size:11px;}
.aside5 ul li.widgetcontainer li {padding:5px 8px 5px;margin:0;line-height:12px;}
.aside5 ul li.widgetcontainer li a {padding:0;margin:0;}
.aside5 ul li.widgetcontainer li ul {padding:5px 0 0;margin:0 0 0 -8px;}
.aside5 ul li.widgetcontainer li ul li a:before {content:"— ";}
.aside5 ul li.widgetcontainer li ul li ul {padding:5px 0 0;margin:0 0 0 8px;}
.aside5 ul li.widget_thematic_search {margin-bottom:44px;}
.aside5 ul li.widget_thematic_search input#s {width:172px;height:14px;padding:2px;overflow:visible;}
.aside5 ul li.widget_text div img {margin:0 -8px;}
.aside5 ul li.widget_text div,
.aside5 ul li.widget_tag_cloud div {padding:0 8px;}[/css] - 5つ目のウィジェットの設定
ダッシュボード > 外観 > ウィジェット に 5th Subsidiary Aside が追加になっているので、
配置したいウィジェットをドラッグして設定
以上で完了!
一応望み通りにできました。。
ふぅ。
[...] AutoFocus+のFooterに新たにWidgetエリアを追加 | azpa! [...]
返信削除