私のワードプレス投稿の画像リンクをすべてリンクしたい:http://www.simafun.com一部の画像を除く。
だから私はこのコードを見つけて使用します:
<?php
function wpguy_linked_image($content){
$searchfor = '/(<img[^>]*\/>)/';
$replacewith = '<a target="_blank" href="'.get_permalink().'">$1</a>';
{
$content = preg_replace($searchfor, $replacewith, $content, -1);
}
return $content;
}
add_filter('the_content', 'wpguy_linked_image');
?>
すべての写真リンクを置き換えますが、写真の前のリンクは削除しません。
最初に前のリンクを削除します。たとえば、「http://www.up.simafun.com/2013/01/police-tabriz-1.jpg」にリンクされた私の画像は、私のサイト名(http://www.simafun.com )
ダウンロードにリンクされている画像など、一部の画像をリンクの変更から除外したい (例: "http://up.simafun.com/download-simafun.com.gif")
下手な英語ですみません。