質問編集履歴
1
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -123,3 +123,67 @@
|
|
123
123
|
|
124
124
|
|
125
125
|
```
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
皆様のおかげでとりあえず動くようにはなりました。
|
130
|
+
|
131
|
+
今回はposttypeが2つしかなかったので以下でも問題なさそうです。
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
### 回答反映例
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
```php
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
<?php
|
144
|
+
|
145
|
+
$args = array(
|
146
|
+
|
147
|
+
'post_type' => array('post','sample'),
|
148
|
+
|
149
|
+
);
|
150
|
+
|
151
|
+
$wp_query = new WP_Query( $args ); ?>
|
152
|
+
|
153
|
+
<?php
|
154
|
+
|
155
|
+
if ( $wp_query->have_posts() ) {
|
156
|
+
|
157
|
+
while ( $wp_query->have_posts() ){
|
158
|
+
|
159
|
+
$wp_query->the_post();
|
160
|
+
|
161
|
+
?>
|
162
|
+
|
163
|
+
<?php $posttype = get_post_type( get_the_ID() );
|
164
|
+
|
165
|
+
if ( $posttype == 'post' ) {
|
166
|
+
|
167
|
+
echo '<h2>'
|
168
|
+
|
169
|
+
. get_the_title() .
|
170
|
+
|
171
|
+
'</h2>';
|
172
|
+
|
173
|
+
} else {
|
174
|
+
|
175
|
+
echo '<h2 class="hoge">' . get_the_title() . '</h2><p> //定型文を表示 </p>';
|
176
|
+
|
177
|
+
} ?>
|
178
|
+
|
179
|
+
<?php
|
180
|
+
|
181
|
+
}
|
182
|
+
|
183
|
+
}
|
184
|
+
|
185
|
+
?>
|
186
|
+
|
187
|
+
|
188
|
+
|
189
|
+
```
|