回答編集履歴

1

追記

2018/10/20 23:11

投稿

CHERRY
CHERRY

スコア25171

test CHANGED
@@ -21,3 +21,35 @@
21
21
  - [https://wpdocs.osdn.jp/テンプレートタグ/get_posts](https://wpdocs.osdn.jp/%E3%83%86%E3%83%B3%E3%83%97%E3%83%AC%E3%83%BC%E3%83%88%E3%82%BF%E3%82%B0/get_posts)
22
22
 
23
23
  - [http://wpdocs.osdn.jp/関数リファレンス/get_children](http://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_children)
24
+
25
+
26
+
27
+ ----
28
+
29
+
30
+
31
+ とりあえず、こんな感じでエラーは出ないと思います。
32
+
33
+
34
+
35
+ ```PHP
36
+
37
+ $myposts = get_posts('posts_per_page' => -1);
38
+
39
+ foreach($myposts as $post){
40
+
41
+ setup_postdata( $post );
42
+
43
+ the_title();
44
+
45
+ $images = get_children( array( 'post_parent' => $post->ID, 'post_type' => 'attachment' );
46
+
47
+ foreach( (array) $images as $attach_id => $attach ){
48
+
49
+ echo wp_get_attachment_link( $attach_id );
50
+
51
+ }
52
+
53
+ }
54
+
55
+ ```