サポート » テーマ » TwentyFourteenのトップページのグリッドを12つにするには?

  • lumierece

    (@lumierece)


    初めまして。lumiereceと申します。
    質問させてください。
    TwentyFourteenのトップページをグリッドにしてあるのですが、ディフォルト初期設定では6つのみ先頭固定表示がなされます。グリッドの数を12に増やすにはどうすればいいですか?phpなど超超初心者なのでお願いします・・・。

11件の返信を表示中 - 1 - 11件目 (全11件中)
  • ishitaka

    (@ishitaka)

    こんにちは

    カスタマイズに設定項目がないので、PHP を記述することになります。
    下記コードを子テーマの functions.php に追加すると12個になります。

    子テーマの functions.php の最後尾(最後尾が ?> の場合は、その上の行)に追加してみてください。

    function twentyfourteen_child_setup() {
    	add_theme_support( 'featured-content', array( 'featured_content_filter' => 'twentyfourteen_get_featured_posts', 'max_posts' => 12 ) );
    }
    add_action( 'after_setup_theme', 'twentyfourteen_child_setup', 11 );

    キャッシュにより変更が反映されない場合があります。その場合は、テーマを一旦親テーマに切り替え、再度子テーマに切り替えてみてください。

    トピック投稿者 lumierece

    (@lumierece)

    @ishitaka-san,

    ご返信、ご回答ありがとうございました。functions.phpに追記はできたのですが、最後のテーマをいったん親テーマに切り替え、再度子テーマに切り替えるという意味が分かりません。キャッシュをクリアするスーパーリロード(Shift+リロードボタン)もしましたし、ブラウザのキャッシュもクリアしてみましたが、反映されていません。こちらの意味をご教示願えますでしょうか?

    構築サイト: https://my-healthcares.com/

    宜しくお願いいたします。
    lumierece

    ishitaka

    (@ishitaka)

    TwentyFourteen テーマの「おすすめコンテンツ」のデータは、テーマによりデータベースにキャッシュ(Transients API)されます。
    このキャッシュは対象の投稿が追加または削除された時と、テーマが有効化された時のみクリアされます。
    言葉が足らず、失礼しました。

    トピック投稿者 lumierece

    (@lumierece)

    @ishitaka-sama,

    昨晩は夜分遅くにご回答いただきありがとうございました。
    私は、wordpress.comのtwentyfourteenのテーマをテーマエディターで追記したのですが、functions.phpの子テーマに追記するのは、単にfuntions.phpをテーマエディターで開いて、最後の行にご説明通りにコピペすればよかったのでしょうか?いまいち子テーマと親テーマの意味が分かっていません。ご教示お願いいたします。サイトはいまだに6グリッドになっています。12にしたいです。

    何卒宜しくお願いいたします。
    lumierece

    トピック投稿者 lumierece

    (@lumierece)

    @ishitaka-sama,

    このような記載がありました。functions.phpファイルの子テーマは、親テーマファイルの前に含まれていますので、子テーマファンクションが使用されます。ヒントになればと思い下にコピペいたしました。大変お手数おかけしておりますが、何卒よろしくお願いいたします。
    *
    * When using a child theme you can override certain functions (those wrapped
    * in a function_exists() call) by defining them first in your child theme’s
    * functions.php file. The child theme’s functions.php file is included before
    * the parent theme’s file, so the child theme functions would be used.

    lumierece

    トピック投稿者 lumierece

    (@lumierece)

    @ishitaka-sama,

    大変お世話になっております。
    featured-content.phpというのがありますが、関係ありますか??下記コピペしました。

    <?php
    /**
    * The template for displaying featured content
    *
    * @package WordPress
    * @subpackage Twenty_Fourteen
    * @since Twenty Fourteen 1.0
    */
    ?>

    <div id=”featured-content” class=”featured-content”>
    <div class=”featured-content-inner”>
    <?php
    /**
    * Fires before the Twenty Fourteen featured content.
    *
    * @since Twenty Fourteen 1.0
    */
    do_action( ‘twentyfourteen_featured_posts_before’ );

    $featured_posts = twentyfourteen_get_featured_posts();
    foreach ( (array) $featured_posts as $order => $post ) :
    setup_postdata( $post );

    // Include the featured content template.
    get_template_part( ‘content’, ‘featured-post’ );
    endforeach;

    /**
    * Fires after the Twenty Fourteen featured content.
    *
    * @since Twenty Fourteen 1.0
    */
    do_action( ‘twentyfourteen_featured_posts_after’ );

    wp_reset_postdata();
    ?>
    </div><!– .featured-content-inner –>
    </div><!– #featured-content .featured-content –>

    ishitaka

    (@ishitaka)

    子テーマについては WordPress Codex 日本語版の「子テーマ」ページをご覧ください。

    子テーマを使用することをおすすめしますが、TwentyFourteen テーマの functions.php の下記部分の「6」の値を変更することでもできます。なお、変更を反映するには、おすすめ投稿を追加するなどしてキャッシュを更新する必要があります。

    // Add support for featured content.
    add_theme_support(
    	'featured-content',
    	array(
    		'featured_content_filter' => 'twentyfourteen_get_featured_posts',
    		'max_posts'               => 6,
    	)
    );

    ※ このフォーラムでコードを貼り付ける場合は、コードを選択し [code] ボタンをクリック(逆クォートで囲む)してください。
    https://ja.wordpress.org/support/article/guidelines/#コードの投稿

    トピック投稿者 lumierece

    (@lumierece)

    @ishitaka ありがとうございました。試したのですが、だめみたいです・・・。

    ishitaka

    (@ishitaka)

    TwentyFourteen テーマ(WP、テーマとも最新バージョン)をインストールして検証してみました。
    結果、functions.php を下記のように変更して、おすすめの投稿(おすすめに設定したタグを追加した投稿)を追加したところ、12個の投稿が表示されました。
    ※ functions.php を変更しただけでは反映されませんでした。

    'max_posts' => 6,

    'max_posts' => 12,

    トピック投稿者 lumierece

    (@lumierece)

    @ishitaka

    ご検証までいただきありがとうございました。
    既存投稿をブログのトップに固定という設定をしてグリッドに表示させようとしていますが、いまだにグリッド数が増えません・・・。キャッシュの問題と思い、スーパーリロードもしましたができませんでした。

    lumierece

    トピック投稿者 lumierece

    (@lumierece)

    @ishitaka
    https://wpdocs.osdn.jp/Twenty_Fourteen

    できました!ありがとうございました!!!

11件の返信を表示中 - 1 - 11件目 (全11件中)
  • トピック「TwentyFourteenのトップページのグリッドを12つにするには?」には新たに返信することはできません。