[外観] > [カスタマイズ] > [Theme Options] > [Layout Options] の Global Layout を Three Columns にしておけば、Three Columns がデフォルトになります。つまり、各投稿・固定ページの編集画面の Layout Settings が Default のままでも、実際のレイアウトは Three Columns になります。
TOPページは1カラムにしたいので、投稿ページに3カラム設定をしてます。
Global Layout は No Sidebar にしておきたい、ということですね。
それでは・・・
下記コードを子テーマの functions.php に入れたらよいかも。
新規投稿のときだけ jQueryでプルダウンの Three Columns を選択します。
無理やりですが・・・
function my_preselect_layout() {
$screen = get_current_screen();
if ( $screen->id == 'post' && $screen->action == 'add' ) {
$script = <<<EOT
<script>
jQuery("#photomania_theme_settings_post_layout").val("three-columns");
</script>
EOT;
echo $script;
}
}
add_action( 'admin_print_footer_scripts', 'my_preselect_layout' );
おはようございます。
子テーマを作ってfunctions.phpを
<?php
add_action( ‘wp_enqueue_scripts’, ‘theme_enqueue_styles’ );
function theme_enqueue_styles() {
wp_enqueue_style( ‘parent-style’, get_template_directory_uri() . ‘/style.css’ );
wp_enqueue_style( ‘child-style’, get_stylesheet_directory_uri() . ‘/style.css’, array(‘parent-style’)
);
}
function my_preselect_layout() {
$screen = get_current_screen();
if ( $screen->id == 'post' && $screen->action == 'add' ) {
$script = <<<EOT
<script>
jQuery("#photomania_theme_settings_post_layout").val("three-columns");
</script>
EOT;
echo $script;
}
}
add_action( 'admin_print_footer_scripts', 'my_preselect_layout' );
?>
画面が真っ白になります…どうしたらいいのでしょうか?
コード部分は逆クォート(`)で囲ってください。
ここに貼り付けた結果、化けたのかもしれませんが・・・ コードの前半のブロックの中のシングルクォートがすべて別の文字になっています。
◆おかしい
add_action( ‘wp_enqueue_scripts’, ‘theme_enqueue_styles’ );
function theme_enqueue_styles() {
wp_enqueue_style( ‘parent-style’, get_template_directory_uri() . ‘/style.css’ );
wp_enqueue_style( ‘child-style’, get_stylesheet_directory_uri() . ‘/style.css’, array(‘parent-style’)
);
}
◆正しい
add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );
function theme_enqueue_styles() {
wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
wp_enqueue_style( 'child-style', get_stylesheet_directory_uri() . '/style.css', array('parent-style')
);
}
実際の functions.php の中ではどうなっていますか。
メール本文に記載されていや物ではなく
フォーラムに記載されていたものを貼り付けたらできました^^
ありがとうございます。
真っ白と聞いて真っ青になりましたが、よかったです ^^
元々の課題が解決したようでしたら、トピックステータスを [解決済み] にしてください。