質問編集履歴
4
ソース
test
CHANGED
File without changes
|
test
CHANGED
@@ -22,7 +22,7 @@
|
|
22
22
|
|
23
23
|
function epress_remove_image_attribute( $html ){
|
24
24
|
|
25
|
-
$html = preg_replace( '/
|
25
|
+
$html = preg_replace( '/alt=(.*)/', '', $html );
|
26
26
|
|
27
27
|
return $html;
|
28
28
|
|
3
the post thumbnail
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
正規表現 置換
|
1
|
+
the post thumbnail alt指定 正規表現 置換
|
test
CHANGED
@@ -1,8 +1,12 @@
|
|
1
1
|
wordpressで作業を行っています。
|
2
2
|
|
3
|
-
altの中身を
|
3
|
+
the post thumbnailで表示されるデフォルトのaltの中身を
|
4
4
|
|
5
|
+
投稿記事タイトルに変えたく正規表現で調べているのですが
|
6
|
+
|
7
|
+
わかりません。
|
8
|
+
|
5
|
-
|
9
|
+
こちらに相談させていただきたく、よろしくお願いします。
|
6
10
|
|
7
11
|
|
8
12
|
|
@@ -14,14 +18,16 @@
|
|
14
18
|
|
15
19
|
```
|
16
20
|
|
17
|
-
|
21
|
+
add_filter( 'post_thumbnail_html', 'epress_remove_image_attribute', 10 );
|
18
22
|
|
19
|
-
|
23
|
+
function epress_remove_image_attribute( $html ){
|
20
24
|
|
25
|
+
$html = preg_replace( '/<\/a>/', '', $html );
|
26
|
+
|
27
|
+
return $html;
|
28
|
+
|
21
|
-
|
29
|
+
}
|
22
30
|
|
23
31
|
|
24
32
|
|
25
|
-
|
33
|
+
```
|
26
|
-
|
27
|
-
$html = 'alt="hello world"';
|
2
タグ
test
CHANGED
File without changes
|
test
CHANGED
File without changes
|
1
得られたい結果
test
CHANGED
File without changes
|
test
CHANGED
@@ -19,3 +19,9 @@
|
|
19
19
|
$html = preg_replace( '/alt=[\'"]([^\'"]+)[\'"]/i', $title, $html );
|
20
20
|
|
21
21
|
```
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
###得られたい結果
|
26
|
+
|
27
|
+
$html = 'alt="hello world"';
|