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