回答編集履歴

2

補足の追加。

2016/04/19 13:29

投稿

kei344
kei344

スコア69407

test CHANGED
@@ -67,3 +67,55 @@
67
67
  add_action( 'init', 'only_my_author_archive' );
68
68
 
69
69
  ```
70
+
71
+
72
+
73
+ ---
74
+
75
+
76
+
77
+ **追記2:**
78
+
79
+
80
+
81
+ カノニカル時に利用されているであろう '%author%' を使っている(記述がある)のが `get_author_posts_url` `get_permalink` の2つのみで、「Edit_Author_Slug」が使用しているのが `get_author_posts_url` 内の `author_link` フックなので、ひとまずこれでいけそう。
82
+
83
+
84
+
85
+ ```PHP
86
+
87
+ add_filter( 'author_rewrite_rules', '__return_empty_array' );
88
+
89
+ function my_author_link( $link = '', $user_id = 0 ) {
90
+
91
+ if ( $user_id > 0 ) {
92
+
93
+ $link = home_url( user_trailingslashit( '/author/'.$user_id ) );
94
+
95
+ }
96
+
97
+ // Return the link.
98
+
99
+ return $link;
100
+
101
+ }
102
+
103
+ add_filter( 'author_link', 'my_author_link', 20, 2 );
104
+
105
+ ```
106
+
107
+
108
+
109
+ (参考)
110
+
111
+
112
+
113
+ 【get_author_posts_url() | Function | WordPress Developer Resources】
114
+
115
+ [https://developer.wordpress.org/reference/functions/get_author_posts_url/](https://developer.wordpress.org/reference/functions/get_author_posts_url/)
116
+
117
+
118
+
119
+ 【get_permalink() | Function | WordPress Developer Resources】
120
+
121
+ [https://developer.wordpress.org/reference/functions/get_permalink/](https://developer.wordpress.org/reference/functions/get_permalink/)

1

補足の追加。

2016/04/19 13:29

投稿

kei344
kei344

スコア69407

test CHANGED
@@ -31,3 +31,39 @@
31
31
  【投稿者アーカイブを無効化してWordPressのユーザ名を隠す方法 | ウェブコンテンツウェブコンテンツ】
32
32
 
33
33
  [http://www.webcontent.jp/no-author-archive/](http://www.webcontent.jp/no-author-archive/)
34
+
35
+
36
+
37
+ ---
38
+
39
+
40
+
41
+ **追記:**
42
+
43
+ > 投稿者アーカイブが利用できなくなるのは避けたいので、
44
+
45
+ > author/admin ではなく author/1 にリダイレクトする
46
+
47
+
48
+
49
+ これでは?
50
+
51
+
52
+
53
+ ```PHP
54
+
55
+ function only_my_author_archive() {
56
+
57
+ if( $_GET[ 'author' ] && $_GET[ 'author' ] > 0 ){
58
+
59
+ wp_redirect( home_url( '/author/'.intval( $_GET[ 'author' ] ) ) );
60
+
61
+ exit;
62
+
63
+ }
64
+
65
+ }
66
+
67
+ add_action( 'init', 'only_my_author_archive' );
68
+
69
+ ```