回答編集履歴
2
コードイメージ追記
answer
CHANGED
|
@@ -6,4 +6,15 @@
|
|
|
6
6
|
パラメータの投稿IDをもとに限定記事かを調べて、
|
|
7
7
|
関数の戻り値で、[会員限定]などの文言を付加する……みたいな感じかなあと想像しました。
|
|
8
8
|
|
|
9
|
-
[https://codex.wordpress.org/Plugin_API/Filter_Reference/the_title](https://codex.wordpress.org/Plugin_API/Filter_Reference/the_title)
|
|
9
|
+
[https://codex.wordpress.org/Plugin_API/Filter_Reference/the_title](https://codex.wordpress.org/Plugin_API/Filter_Reference/the_title)
|
|
10
|
+
|
|
11
|
+
```PHP
|
|
12
|
+
function my_the_title( $title, $id ) {
|
|
13
|
+
|
|
14
|
+
// $idをもとにして、限定記事が調べる処理
|
|
15
|
+
// ex) データベースをたたいて調べる……など
|
|
16
|
+
|
|
17
|
+
return '[会員限定]' . $title;
|
|
18
|
+
}
|
|
19
|
+
add_filter( 'the_title', 'my_the_title', 10, 2 );
|
|
20
|
+
```
|
1
参考URL追記
answer
CHANGED
|
@@ -4,4 +4,6 @@
|
|
|
4
4
|
|
|
5
5
|
実装する場合は、`the_title`フィルターに関数をフックして、
|
|
6
6
|
パラメータの投稿IDをもとに限定記事かを調べて、
|
|
7
|
-
関数の戻り値で、[会員限定]などの文言を付加する……みたいな感じかなあと想像しました。
|
|
7
|
+
関数の戻り値で、[会員限定]などの文言を付加する……みたいな感じかなあと想像しました。
|
|
8
|
+
|
|
9
|
+
[https://codex.wordpress.org/Plugin_API/Filter_Reference/the_title](https://codex.wordpress.org/Plugin_API/Filter_Reference/the_title)
|