回答編集履歴

3

修正

2023/01/14 11:24

投稿

CHERRY
CHERRY

スコア25171

test CHANGED
@@ -6,7 +6,7 @@
6
6
  $args1 = array(
7
7
  'post_type' => 'blog1';
8
8
  );
9
- $subquery1 = WP_Query($args1);
9
+ $subquery1 = new WP_Query($args1);
10
10
  ?>
11
11
 
12
12
  <?php if ($subquery1->have_posts()) : ?>
@@ -23,7 +23,7 @@
23
23
  $args2 = array(
24
24
  'post_type' => 'blog2';
25
25
  );
26
- $subquery2 = WP_Query($args2);
26
+ $subquery2 = new WP_Query($args2);
27
27
  ?>
28
28
 
29
29
  <?php if ($subquery2->have_posts()) : ?>

2

コードの修正

2023/01/14 11:22

投稿

CHERRY
CHERRY

スコア25171

test CHANGED
@@ -4,7 +4,7 @@
4
4
  // blog1 を表示
5
5
  <?php
6
6
  $args1 = array(
7
- 'post_type' => 'blog1':
7
+ 'post_type' => 'blog1';
8
8
  );
9
9
  $subquery1 = WP_Query($args1);
10
10
  ?>
@@ -21,7 +21,7 @@
21
21
  // blog2 を表示
22
22
  <?php
23
23
  $args2 = array(
24
- 'post_type' => 'blog2':
24
+ 'post_type' => 'blog2';
25
25
  );
26
26
  $subquery2 = WP_Query($args2);
27
27
  ?>

1

コードの修正

2023/01/14 09:00

投稿

CHERRY
CHERRY

スコア25171

test CHANGED
@@ -3,14 +3,14 @@
3
3
  ```
4
4
  // blog1 を表示
5
5
  <?php
6
- $args = array(
6
+ $args1 = array(
7
7
  'post_type' => 'blog1':
8
8
  );
9
- $subquery = WP_Query($args);
9
+ $subquery1 = WP_Query($args1);
10
10
  ?>
11
11
 
12
- <?php if ($subquery->have_posts()) : ?>
12
+ <?php if ($subquery1->have_posts()) : ?>
13
- <?php while ($subquery->have_posts()) : $subquery->the_post(); ?>
13
+ <?php while ($subquery1->have_posts()) : $subquery1->the_post(); ?>
14
14
  <div>
15
15
  <a href="<?php the_permalink(); ?>"></a>
16
16
  </div>
@@ -20,14 +20,14 @@
20
20
 
21
21
  // blog2 を表示
22
22
  <?php
23
- $args = array(
23
+ $args2 = array(
24
- 'post_type' => 'blog1':
24
+ 'post_type' => 'blog2':
25
25
  );
26
- $subquery = WP_Query($args);
26
+ $subquery2 = WP_Query($args2);
27
27
  ?>
28
28
 
29
- <?php if ($subquery->have_posts()) : ?>
29
+ <?php if ($subquery2->have_posts()) : ?>
30
- <?php while ($subquery->have_posts()) : $subquery->the_post(); ?>
30
+ <?php while ($subquery2->have_posts()) : $subquery2->the_post(); ?>
31
31
  <div>
32
32
  <a href="<?php the_permalink(); ?>"></a>
33
33
  </div>