回答編集履歴
1
解決策に変更
test
CHANGED
@@ -1,19 +1,65 @@
|
|
1
|
-
|
1
|
+
カスタム投稿タイプ:shop
|
2
|
-
|
3
|
-
カスタム投稿タイプお知らせの一覧を表示する際に、カスタム投稿タイプ店舗の県の項目で抽出して表示したいのですが、そのような条件をmeta_queryで書くことは可能なのでしょうか?
|
4
2
|
|
5
3
|
|
6
4
|
|
7
|
-
|
5
|
+
カスタム投稿タイプ:news
|
8
6
|
|
9
|
-
|
7
|
+
カスタムフィールド:shop ・・・ shopの投稿IDを保持
|
10
|
-
|
11
|
-
-その他の項目
|
12
8
|
|
13
9
|
|
14
10
|
|
15
|
-
・カスタム投稿タイプ店舗
|
16
11
|
|
17
|
-
-県
|
18
12
|
|
13
|
+
以下のコードは、single-shop.php の中の話です。
|
14
|
+
|
15
|
+
以下のような処理を組んでとりあえずは動く状態にはしました。
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
```php
|
20
|
+
|
21
|
+
$thisPageId = get_the_ID();
|
22
|
+
|
23
|
+
$args = array(
|
24
|
+
|
25
|
+
'post_type' => 'news',
|
26
|
+
|
27
|
+
'posts_per_page' => 10000
|
28
|
+
|
29
|
+
);
|
30
|
+
|
31
|
+
$myposts = get_posts( $args );
|
32
|
+
|
33
|
+
foreach ( $myposts as $post ) : setup_postdata( $post );
|
34
|
+
|
35
|
+
if(SCF::get("shop")[0] == $thisPageId){
|
36
|
+
|
37
|
+
?>
|
38
|
+
|
39
|
+
<li>
|
40
|
+
|
41
|
+
<p><span class="date"><?php the_time("Y.m.d") ?></span></p>
|
42
|
+
|
43
|
+
<p><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></p>
|
44
|
+
|
45
|
+
</li>
|
46
|
+
|
19
|
-
|
47
|
+
<?php
|
48
|
+
|
49
|
+
}
|
50
|
+
|
51
|
+
endforeach;
|
52
|
+
|
53
|
+
wp_reset_postdata();
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
```
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
get_postsで記事を抽出する段階でもっと良い処理が組める場合はそちらを教えていただけると幸いです。
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
|