Q.トップページのニュースティッカーを、最新のお知らせ1つに固定することはできますか?
テーマで設定できる最小数は3のため、1つに固定する場合はテーマファイルの編集が必要になります。
▼変更箇所イメージ
A.下記の方法でカスタマイズしてください。
編集するファイル: ホームページ (front-page.php)
編集する箇所: 110行目~114行目付近
$args = array( 'post_type' => $post_type, 'posts_per_page' => $post_num, 'orderby' => 'rand' ); } elseif($post_type == 'featured') { $args = array('post_type' => 'featured', 'posts_per_page' => $post_num, 'ignore_sticky_posts' => 1, 'orderby' => array('menu_order' => 'ASC', 'date' => 'DESC')); } else { $args = array( 'post_type' => $post_type, 'posts_per_page' => $post_num );
↓
$args = array( 'post_type' => $post_type, 'posts_per_page' => 1, 'orderby' => 'rand' ); } elseif($post_type == 'featured') { $args = array('post_type' => 'featured', 'posts_per_page' => 1, 'ignore_sticky_posts' => 1, 'orderby' => array('menu_order' => 'ASC', 'date' => 'DESC')); } else { $args = array( 'post_type' => $post_type, 'posts_per_page' => 1 );
「$post_num」を「1」に編集する形になります。
この記事は役に立ちましたか?
もし参考になりましたら、下のボタンで教えてください。
今後の記事作成の参考とさせて頂きます!