質問するログイン新規登録

質問編集履歴

4

ソース

2016/07/19 04:13

投稿

test21
test21

スコア30

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( '/<\/a>/', '', $html );
13
+ $html = preg_replace( '/alt=(.*)/', '', $html );
14
14
  return $html;
15
15
  }
16
16
 

3

the post thumbnail

2016/07/19 04:12

投稿

test21
test21

スコア30

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
- altの中身を変数の内容に変えたいのですが正規表現に明くなく
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
- $title = "hello world";
12
+ function epress_remove_image_attribute( $html ){
10
- $html = preg_replace( '/alt=[\'"]([^\'"]+)[\'"]/i', $title, $html );
13
+ $html = preg_replace( '/<\/a>/', '', $html );
14
+ return $html;
11
- ```
15
+ }
12
16
 
13
- ###得られたい結果
17
+ ```
14
- $html = 'alt="hello world"';

2

タグ

2016/07/19 03:54

投稿

test21
test21

スコア30

title CHANGED
File without changes
body CHANGED
File without changes

1

得られたい結果

2016/07/19 03:35

投稿

test21
test21

スコア30

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