質問編集履歴

2

ご質問の回答用追記記述

2023/03/12 14:37

投稿

NNC
NNC

スコア22

test CHANGED
File without changes
test CHANGED
@@ -74,7 +74,7 @@
74
74
  お手数ですが、お知恵をお借りできれば幸いです。
75
75
  よろしくお願いいたします。
76
76
   
77
- ### 【ご回答用の追記】
77
+ ### 【ご回答用の追記※トップページも同一記述
78
78
  ```
79
79
  【一覧】
80
80
  <ul class="food_list">

1

ご質問への回答用に追記

2023/03/12 11:18

投稿

NNC
NNC

スコア22

test CHANGED
File without changes
test CHANGED
@@ -73,4 +73,42 @@
73
73
   
74
74
  お手数ですが、お知恵をお借りできれば幸いです。
75
75
  よろしくお願いいたします。
76
+  
76
-
77
+ ### 【ご回答用の追記】
78
+ ```
79
+ 【一覧】
80
+ <ul class="food_list">
81
+ <?php
82
+ $paged = (int) get_query_var('paged');
83
+ $args = array(
84
+ 'posts_per_page' => 5,
85
+ 'paged' => $paged,
86
+ 'orderby' => 'post_date',
87
+ 'order' => 'DESC',
88
+ 'post_type' => 'post',
89
+ 'post_status' => 'publish'
90
+ );
91
+ $the_query = new WP_Query($args);
92
+ if ( $the_query->have_posts() ) :
93
+ while ( $the_query->have_posts() ) : $the_query->the_post();
94
+ get_template_part( 'foodlist', get_post_format() );
95
+ endwhile;
96
+ endif;
97
+ wp_reset_postdata();
98
+ ?>
99
+ </ul>
100
+  
101
+ 【foodlistの中身】
102
+ <li class="foodbox">
103
+ <div class="food_table">
104
+ <div class="food_th">
105
+ <h3><?php the_title(); ?></h3>
106
+ </div>
107
+ <div class="food_td">
108
+ <div class="favorite_button" data-pageid="<?php the_ID(); ?>">
109
+ <button class="favorite_button_in" onclick="window.location.reload();"><p>お気に入り登録</p></button>
110
+ </div>
111
+ </div>
112
+ </div>
113
+ </li>
114
+ ```