Q.トップページの「最近の記事」を古い順に表示させたい
最近の記事を古い順で表示させたいのですがどのファイルを編集すればよいでしょうか?また、おすすめカテゴリー1.2.3を設定した場合、これらにも記事が古い順に表示させたいです。
A.下記のphpファイルの該当箇所を編集します
①最近の記事を昇順にする
編集するファイル:index.php
編集する箇所:
<?php // Recent post --------------------------------------------------------------------------------------- ?> <div id="index_recent_post"> <h3 class="headline1"><?php _e("Recent post","tcd-w"); ?><span><?php next_posts_link(__('Archives', 'tcd-w')) ?></span></h3> <?php $odd_or_even = 'odd'; $args = array('post_type' => 'post', 'posts_per_page' => 6);
↓
<?php // Recent post --------------------------------------------------------------------------------------- ?> <div id="index_recent_post"> <h3 class="headline1"><?php _e("Recent post","tcd-w"); ?><span><?php next_posts_link(__('Archives', 'tcd-w')) ?></span></h3> <?php $odd_or_even = 'odd'; $args = array('post_type' => 'post', 'posts_per_page' => 6, 'order' => ASC);
※最後の行6の横に「, ‘order’ => ASC」を追加してください。
②おすすめカテゴリー1.2.3を昇順にする
編集するファイル:index.php
編集する箇所:
<?php // Category post1 --------------------------------------------------------------------------------------- ?> <?php if($options['index_category1']) { $cat_id1 = $options['index_category1']; $cat_info1 = get_category($cat_id1); $args = array('post_type' => 'post', 'numberposts' => 5, 'category' => $cat_id1, 'order' => ASC); $index_category_post1 = get_posts($args); ?> <?php // Category post2 --------------------------------------------------------------------------------------- ?> <?php if($options['index_category2']) { $cat_id2 = $options['index_category2']; $cat_info2 = get_category($cat_id2); $args = array('post_type' => 'post', 'numberposts' => 5, 'category' => $cat_id2, 'order' => ASC); $index_category_post2 = get_posts($args); ?> <?php // Category post3 --------------------------------------------------------------------------------------- ?> <?php if($options['index_category3']) { $cat_id3 = $options['index_category3']; $cat_info3 = get_category($cat_id3); $args = array('post_type' => 'post', 'numberposts' => 5, 'category' => $cat_id3, 'order' => ASC); $index_category_post3 = get_posts($args); ?>
※「, ‘order’ => ASC」を $cat_id●のあとに追加しています。
この記事は役に立ちましたか?
もし参考になりましたら、下のボタンで教えてください。
今後の記事作成の参考とさせて頂きます!