https://test1.veronica9.com/columnlist/
上記の1ページに投稿一覧を6つ表示したかったので、
wordpressの表示設定の1ページに表示する最大投稿数を6にすると、
TOPページのコラムの表示も6つになってしまい、
TOPページのコラムの投稿一覧の表示を3つにする場合は、
どのようにすればよいか、お分かりになられる方がいらっしゃれば、
ご教授頂けますと幸いです。
よろしくお願い致します。
home.php
⇓
PHP
1<section class="column"> 2<?php get_template_part('include/liststyle/post-list-mag'); ?> 3</section>
include/liststyle/post-list-mag.php
⇓
PHP
1<?php if( ! get_theme_mod('toppost_list_cat') ) :?> 2<div class="toppost-list-box-simple"> 3 <div class="post-list-mag"> 4 5 <?php 6 $ad_infeed_pc_num = get_option('ad_infeed_pc_num'); 7 $ad_infeed_sp_num = get_option('ad_infeed_sp_num'); 8 ?> 9 <?php if( isset($ad_infeed_pc_num) || isset($ad_infeed_sp_num) ) :?> 10 <?php get_template_part('include/liststyle/parts/post-list-mag-parts-infeed'); ?> 11 <?php else: ?> 12 <?php while (have_posts()) : the_post(); ?> 13 <?php get_template_part('include/liststyle/parts/post-list-mag-parts'); ?> 14 <?php endwhile; ?> 15 <?php endif; ?> 16 17 <section class="pager-top"> 18 <?php if( function_exists('responsive_pagination') ) { responsive_pagination( $wp_query->max_num_pages ); } ?> 19 </section> 20 </div> 21</div> 22<?php else: ?> 23<div class="toppost-list-box"> 24 <div class="column_back"> 25 <h2 class="column_title">コラム 26<!-- <img src="https://test1.veronica9.com/wp-content/uploads/2021/01/column.png" alt="Step to C"> --> 27 </h2></div> 28 <?php 29 $toppost_list_cat = get_theme_mod('toppost_list_cat'); 30 $list_cat_id = explode(",", $toppost_list_cat); 31 $list_cat_num = 0; 32 $list_cat_num2 = 0; 33 ?> 34 <input type="radio" name="switch" id="tab-1" checked> 35 <input type="radio" name="switch" id="tab-2"> 36 <input type="radio" name="switch" id="tab-3"> 37 <input type="radio" name="switch" id="tab-4"> 38 <input type="radio" name="switch" id="tab-5"> 39 40 <ul class="tabBtn-mag"> 41 <li><label for="tab-1"><?php echo get_theme_mod('jin_toppost_list_name','最新記事'); ?></label></li> 42 <?php while( isset($list_cat_id[$list_cat_num2]) ): ?> 43 <?php 44 // カテゴリー情報を取得 45 $category_tab = get_category($list_cat_id[$list_cat_num2]); 46 $cat_name_tab = $category_tab->cat_name; 47 ?> 48 <li><label for="tab-<?php echo $list_cat_num2+2; ?>"><?php echo $cat_name_tab; ?></label></li> 49 <?php $list_cat_num2++; ?> 50 <?php endwhile; ?> 51 </ul> 52 <div class="toppost-list-box-inner"> 53 54 <div class="post-list-mag autoheight"> 55 56 <?php 57 $ad_infeed_pc_num = get_option('ad_infeed_pc_num'); 58 $ad_infeed_sp_num = get_option('ad_infeed_sp_num'); 59 ?> 60 <?php if( isset($ad_infeed_pc_num) || isset($ad_infeed_sp_num) ) :?> 61 <?php get_template_part('include/liststyle/parts/post-list-mag-parts-infeed'); ?> 62 <?php else: ?> 63 <?php while (have_posts()) : the_post(); ?> 64 <?php get_template_part('include/liststyle/parts/post-list-mag-parts'); ?> 65 <?php endwhile; ?> 66 <?php endif; ?> 67 68 <section class="pager-top"> 69 <?php if( function_exists('responsive_pagination') ) { responsive_pagination( $wp_query->max_num_pages ); } ?> 70 </section> 71 </div> 72 73 74 <?php while( isset($list_cat_id[$list_cat_num]) ): ?> 75 76 <div class="post-list-mag autoheight"> 77 78 <?php 79 $child_categories = get_term_children($list_cat_id[$list_cat_num], 'category'); 80 $cat_url = get_category_link($list_cat_id[$list_cat_num]); 81 $cat_url = rtrim($cat_url, '/'); 82 $parent_cat_id = $list_cat_id[$list_cat_num]; 83 84 if( $child_categories ){// 子カテゴリーがあるとき 85 $all_cat_id = $list_cat_id[$list_cat_num]; 86 $child_categories_total = count($child_categories); 87 88 if( get_category($all_cat_id)->parent == 0 ){ 89 foreach ($child_categories as $key => $value) { 90 $all_cat_id .= ','.$value; 91 $child_cat_count[$key] = get_category($value)->count; 92 } 93 $cat_count_child = 0; 94 for( $i = 0 ; $i < $child_categories_total; $i++){ 95 $cat_count_child += $child_cat_count[$i]; 96 } 97 $cat_count = $cat_count_child + get_category($parent_cat_id)->count; 98 }else{ 99 foreach ($child_categories as $key => $value) { 100 $all_cat_id .= ','.$value; 101 $child_cat_count[$key] = get_category($value)->count; 102 } 103 $all_cat_id_each = explode(",", $all_cat_id); 104 $all_cat_id2 = count($all_cat_id_each); 105 $cat_count_child = 0; 106 for( $i = 0 ; $i < $all_cat_id2 - 1; $i++){ 107 $cat_count_child += $child_cat_count[$i]; 108 } 109 $cat_count = $cat_count_child + get_category($parent_cat_id)->count; 110 } 111 } 112 else{// 子カテゴリーがないとき 113 $cat_count = get_category($parent_cat_id)->count; 114 } 115 $args = array( 116 'cat' => array($parent_cat_id), 117 'posts_per_page' => get_option('posts_per_page'), 118 ); 119 $the_query = new WP_Query( $args ); 120 ?> 121 <?php while ( $the_query->have_posts() ) : $the_query->the_post() ?> 122 <?php 123 // カテゴリー情報を取得 124 $category = get_the_category(); 125 $cat_id = $category[0]->cat_ID; 126 $cat_name = $category[0]->cat_name; 127 ?> 128 129 <?php get_template_part('include/liststyle/parts/post-list-mag-parts'); ?> 130 131 <?php endwhile; ?> 132 133 <?php if( isset( $cat_url ) && $cat_count > get_option('posts_per_page') ) :?> 134 135 <?php if( strstr( $cat_url,'/?' ) == false ): ?> 136 <div class="more-cat"> 137 <div class="more-cat-button ef"><a href="<?php echo $cat_url; ?>/page/2/"><span>next</span></a></div> 138 </div> 139 <?php else: ?> 140 <div class="more-cat"> 141 <div class="more-cat-button ef"><a href="<?php echo $cat_url; ?>&paged=2"><span>next</span></a></div> 142 </div> 143 <?php endif; ?> 144 <?php endif; ?> 145 </div> 146 147 <?php $list_cat_num++; ?> 148 <?php endwhile; ?> 149 150 </div> 151 152</div> 153<?php endif; ?>
回答2件
あなたの回答
tips
プレビュー