質問編集履歴

1

回答を参考に「変更①」へ変更

2024/03/30 18:17

投稿

TMTN
TMTN

スコア53

test CHANGED
File without changes
test CHANGED
@@ -43,6 +43,39 @@
43
43
  <?php endwhile:?>
44
44
  ```
45
45
 
46
+ ### 変更①
47
+
48
+ ```php
49
+ <?php while(have_posts()):?>
50
+ <section class="page-section">
51
+ <div class="container">
52
+ <div class="product-item">
53
+ <div class="product-item-title d-flex">
54
+ <div class="bg-faded p-5 d-flex me-auto rounded">
55
+ <h2 class="section-heading mb-0">
56
+ <span class="section-heading-upper"><?php the_post();?></span>
57
+ <span class="section-heading-lower"><?php the_title();?></span>
58
+
59
+ </h2>
60
+ </div>
61
+ </div>
62
+ <img class="product-item-img mx-auto d-flex rounded img-fluid mb-3 mb-lg-0" src="<?php echo $img[0]; ?>" alt="..." />
63
+ <div class="product-item-description d-flex ms-auto">
64
+ <div class="bg-faded p-5 rounded">
65
+ <p class="mb-0"><?php the_content();?>
66
+
67
+ Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
68
+ </p>
69
+
70
+ </div>
71
+ </div>
72
+ </div>
73
+ </div>
74
+ </section>
75
+
76
+ <?php endwhile;?>
77
+ ```
78
+
46
79
  ### 試したこと・調べたこと
47
80
  - [x] teratailやGoogle等で検索した
48
81
  - [x] ソースコードを自分なりに変更した
@@ -54,3 +87,6 @@
54
87
 
55
88
  ### 補足
56
89
  特になし
90
+
91
+ ##### 上記の変更①の結果
92
+ the_post() をget_posts()に変更、または、have_post()をget_posts()へ変更した場合、両方無限ループに入ってしましました。