質問編集履歴

2

$argsにタクソノミーの情報を渡しましたが、記事の取得ができなくなってしまいました。。。タームで絞り込めば取得が出来るのですが、特定のタームで絞り込む意図が今回ありません。

2018/04/16 15:20

投稿

nakasea
nakasea

スコア6

test CHANGED
File without changes
test CHANGED
@@ -38,11 +38,31 @@
38
38
 
39
39
  <?php
40
40
 
41
+ $args = array(
42
+
41
- $args = array( 'post_type' => 'introduce' );
43
+ 'post_type' => 'introduce',
44
+
45
+ 'tax_query' => array(
46
+
47
+ array(
48
+
49
+ 'taxonomy' => 'category6',
50
+
51
+ 'field' => 'slug',
52
+
53
+ ),
54
+
55
+ ),
56
+
57
+ );
42
58
 
43
59
  $the_query = new WP_Query( $args );
44
60
 
61
+ ?>
62
+
45
- if ( $the_query->have_posts() ) : ?>
63
+ <?php if ( $the_query->have_posts() ) : ?>
64
+
65
+
46
66
 
47
67
  <div id="introduce_list">
48
68
 
@@ -50,19 +70,19 @@
50
70
 
51
71
  <?php
52
72
 
53
- $i = 0;
73
+ $i = 0;
54
74
 
55
- $row = 0;
75
+ $row = 0;
56
76
 
57
- while ( $the_query->have_posts() ) :
77
+ while ( $the_query->have_posts() ) :
58
78
 
59
- $the_query->the_post();
79
+ $the_query->the_post();
60
80
 
61
81
 
62
82
 
63
- if ($i > 0 && $i % 3 == 0) {
83
+ if ($i > 0 && $i % 3 == 0) {
64
84
 
65
- $row++;
85
+ $row++;
66
86
 
67
87
  ?>
68
88
 
@@ -72,29 +92,29 @@
72
92
 
73
93
  <?php
74
94
 
75
- }
95
+ }
76
96
 
77
97
 
78
98
 
79
- $col_class = '';
99
+ $col_class = '';
80
100
 
81
- if ($row % 2 == 0) {
101
+ if ($row % 2 == 0) {
82
102
 
83
- if ($i % 3 == 0) {
103
+ if ($i % 3 == 0) {
84
104
 
85
- $col_class = ' show_info';
105
+ $col_class = ' show_info';
86
106
 
87
- }
107
+ }
88
108
 
89
- } else {
109
+ } else {
90
110
 
91
- if ($i % 3 == 2) {
111
+ if ($i % 3 == 2) {
92
112
 
93
- $col_class = ' show_info';
113
+ $col_class = ' show_info';
94
114
 
95
- }
115
+ }
96
116
 
97
- }
117
+ }
98
118
 
99
119
  ?>
100
120
 
@@ -158,6 +178,8 @@
158
178
 
159
179
  <?php $i++; endwhile; ?>
160
180
 
181
+ <?php wp_reset_postdata(); ?>
182
+
161
183
 
162
184
 
163
185
  </div>

1

2018/04/16 15:20

投稿

nakasea
nakasea

スコア6

test CHANGED
File without changes
test CHANGED
File without changes