「TCD AWARD 2023」受賞サイトを発表しました。

ワードプレステーマ別

TCDテーマPrecious:お知らせ・商品・ブログの表示数を変更する

Q.お知らせ・商品・ブログの表示数を変更する

TOPページにおけるデフォルトの表示数は
お知らせ:3つ
商品:6アイテム
ブログ:3記事
となっています。
これを任意の数に変更する方法は以下のようになります。

A.下記のphpファイルの該当箇所を編集します

■お知らせの数を変更する場合
編集するファイル:index.php
編集する箇所:

  <!-- index news -->
 <?php if ($options['show_index_news']) { ?>
 <div id="index_news">
  <h3 class="headline1"><span><?php echo $options['index_headline_news']; ?></span></h3>
  <ol class="clearfix">
   <?php
        $args = array('post_type' => 'news', 'numberposts' => 3);
        $news_post=get_posts($args);
        if ($news_post) :
        foreach ($news_post as $post) : setup_postdata ($post);
   ?>

※「 ‘numberposts’ => 3 」部分の「3」を任意の数値に変更します。

■商品数を変更する場合
編集するファイル:index.php
編集する箇所:

 <!-- product list -->
 <?php
      if ($options['show_index_product']) {
      $args = array('post_type' => 'product', 'numberposts' => 6);
      $product_post=get_posts($args);
      if ($product_post) {
 ?>

※「 ‘numberposts’ => 6 」部分の「6」を任意の数値に変更します。

■ブログの記事数を変更する場合
編集するファイル:index.php
編集する箇所:

 <!-- blog list -->
 <?php if ($options['show_index_blog']) { ?>
 <div id="index_blog">
  <h3 class="headline1"><span><?php echo $options['index_headline_blog']; ?></span></h3>
  <ol class="clearfix">
   <?php
        $args = array('post_type' => 'post', 'numberposts' => 3);
        $index_recent_post=get_posts($args);
        if ($index_recent_post) :
        foreach ($index_recent_post as $post) : setup_postdata ($post);
   ?>

※「 ‘numberposts’ => 3 」部分の「3」を任意の数値に変更します。

この記事は役に立ちましたか?

もし参考になりましたら、下のボタンで教えてください。
今後の記事作成の参考とさせて頂きます!

同じテーマのカスタマイズ記事