回答編集履歴
2
test
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
|
1
|
+
query_postsは推奨されてないのでWP_Queryを使いましょう。
|
2
2
|
|
3
|
-
|
3
|
+
wp_get_current_userでログインユーザー情報を取得できます。
|
4
4
|
|
5
5
|
|
6
6
|
|
@@ -20,4 +20,44 @@
|
|
20
20
|
|
21
21
|
**追記**
|
22
22
|
|
23
|
-
ふと気付きましたが、提示されたコードの6行目の
|
23
|
+
ふと気付きましたが、提示されたコードの6行目の<?php endif; ?>は、このままのコードだと要りません。と言うかエラーになるはずです。
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
**追記**
|
32
|
+
|
33
|
+
こんな感じで
|
34
|
+
|
35
|
+
```
|
36
|
+
|
37
|
+
<?php
|
38
|
+
|
39
|
+
$current_user = wp_get_current_user();
|
40
|
+
|
41
|
+
$user_id = $current_user->ID;
|
42
|
+
|
43
|
+
$query = new WP_Query(
|
44
|
+
|
45
|
+
array(
|
46
|
+
|
47
|
+
'author' => $user_id,
|
48
|
+
|
49
|
+
'posts_per_page' => 5,
|
50
|
+
|
51
|
+
)
|
52
|
+
|
53
|
+
);
|
54
|
+
|
55
|
+
if ( $query->have_posts() ):
|
56
|
+
|
57
|
+
while ( $query->have_posts() ):
|
58
|
+
|
59
|
+
$query->the_post();
|
60
|
+
|
61
|
+
?>
|
62
|
+
|
63
|
+
```
|
1
test
CHANGED
@@ -15,3 +15,9 @@
|
|
15
15
|
Function Reference/wp get current user
|
16
16
|
|
17
17
|
[https://codex.wordpress.org/wp_get_current_user](https://codex.wordpress.org/wp_get_current_user)
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
**追記**
|
22
|
+
|
23
|
+
ふと気付きましたが、提示されたコードの6行目の```<?php endif; ?>```は、このままのコードだと要りません。と言うかエラーになるはずです。
|