質問編集履歴

4

ソース

2016/07/19 04:13

投稿

test21
test21

スコア30

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( '/<\/a>/', '', $html );
25
+ $html = preg_replace( '/alt=(.*)/', '', $html );
26
26
 
27
27
  return $html;
28
28
 

3

the post thumbnail

2016/07/19 04:12

投稿

test21
test21

スコア30

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
- $title = "hello world";
21
+ add_filter( 'post_thumbnail_html', 'epress_remove_image_attribute', 10 );
18
22
 
19
- $html = preg_replace( '/alt=[\'"]([^\'"]+)[\'"]/i', $title, $html );
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

タグ

2016/07/19 03:54

投稿

test21
test21

スコア30

test CHANGED
File without changes
test CHANGED
File without changes

1

得られたい結果

2016/07/19 03:35

投稿

test21
test21

スコア30

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"';