TwentyFourteenをモノカラムにする

WordPressのデフォルトテーマのTwentyFourteenをモノカラム化した際の覚書。

TwentyFourteenは、もともとトリプルカラム(3カラム)のテーマだが、これをモノカラム(1カラム)にする。

編集画面でテンプレートを選択できる固定ページやカスタムポストに関しては、従来、過去の記事に書いてあるように、1カラム化できていたので、その部分は今回はいじらず。テンプレート選択できない、投稿記事、またアーカイブ表示(トップページなど)を改造の対象とする。

【対象】
・TwentyFourteen:ver3.8(WordPress 6.4.3環境で実施)
・改造するもの:Stylesheet(style.css)、Single Post(single.php)、Main Index Templates(index.php)

【段取り】
・TwentyFourteenの子テーマを作る
・子テーマの中に、style.css、single.php、index.phpの3つを用意する。single.php、index.phpは、親テーマTwentyFourteenのファイルをコピーしてよい。
・以下各ファイルの改造点を説明する

【single.php】
文末のsidebar(ウィジッドエリア)に関する記述2行を削除する。

<?php
get_sidebar( 'content' );
get_sidebar();
get_footer();

以下のように変更。

<?php

get_footer();

【index.php】
文末のsidebar(ウィジッドエリア)に関する記述2行を削除する。

<?php
get_sidebar();
get_footer();

以下のように変更。

<?php

get_footer();

【style.css】
以下の文言を記述。Width関連の変更点以外を修正すると、色々見た目を変えられる。

/* 
左側のウィジッドエリアに関する記述。widthで横幅を規定→0にする
*/

.site:before {
		background-color: #000;
		content: "";
		display: block;
		height: 100%;
		min-height: 100%;
		position: absolute;
		top: 0;
		left: 0;
		width: 0px;
		z-index: 2;
	}

/* 
右側のウィジッドエリアに関する記述。widthで横幅を規定→0にする
*/

.secondary-navigation {
		font-size: 11px;
		margin: 0 -0px 0px;
		width: 0px;
	}

.secondary-navigation ul ul {
		background-color: #24890d;
		position: absolute;
		top: 0;
		left: 0em;
		width: 0px;
		z-index: 99999;
	}

/*
コメントエリアに関する記述。max-widthで横幅を規定
*/

.site-content {
		margin-right: 0px;
		margin-left: 0px;
	}

.site-content .entry-header,
.site-content .entry-content,
.site-content .entry-summary,
.site-content .entry-meta,
.page-content {
	margin: 0 auto;
	max-width: 1100px;
}

/*
コメントエリアに関する記述。max-widthで横幅を規定
*/

.comments-area {
	margin: 48px auto;
	max-width: 1000px;
	padding: 0 10px;
}

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です