回答編集履歴

2

追記の追記

2018/03/11 11:26

投稿

8-0_nyan5
8-0_nyan5

スコア2352

test CHANGED
@@ -29,3 +29,37 @@
29
29
  $post_id = $post_id->ID;
30
30
 
31
31
  ```
32
+
33
+
34
+
35
+ 追記2
36
+
37
+ ---
38
+
39
+ ```php
40
+
41
+ $custom_fields = get_post_custom();
42
+
43
+ $my_custom_field = $custom_fields['animal'];
44
+
45
+ foreach( $my_custom_field as $key => $value )
46
+
47
+
48
+
49
+ $post_id = get_page_by_path( $value, "OBJECT", "xxxtype" );
50
+
51
+ $post_id = $post_id->ID;
52
+
53
+
54
+
55
+ echo get_post_meta( $post_id, 'cry', true );
56
+
57
+
58
+
59
+ ```
60
+
61
+
62
+
63
+ [関数リファレンス/get page by path](https://wpdocs.osdn.jp/%E9%96%A2%E6%95%B0%E3%83%AA%E3%83%95%E3%82%A1%E3%83%AC%E3%83%B3%E3%82%B9/get_page_by_path)
64
+
65
+ https://wpdocs.osdn.jp/%E9%96%A2%E6%95%B0%E3%83%AA%E3%83%95%E3%82%A1%E3%83%AC%E3%83%B3%E3%82%B9/get_page_by_path

1

追記

2018/03/11 11:26

投稿

8-0_nyan5
8-0_nyan5

スコア2352

test CHANGED
@@ -13,3 +13,19 @@
13
13
 
14
14
 
15
15
  参考まで。
16
+
17
+
18
+
19
+ 追記
20
+
21
+ ---
22
+
23
+ 参考ページでは、「post」で書かれていますが、そこを「カスタム投稿のスラッグ」に変えればいけると思います。
24
+
25
+ ```ここに言語を入力
26
+
27
+ $post_id = get_page_by_path("sulg_name", "OBJECT", "カスタム投稿のスラッグ");
28
+
29
+ $post_id = $post_id->ID;
30
+
31
+ ```