jQuery
$("a[href^='http://']").attr("target","_blank");
$('a[target="_blank"]').after(' <i class="fa fa-external-link"></i>');
こんな感じ 詰めが必要
CSS
Font Awesome 5 を利用
/* 外部リンクアイコン付き */
.entry-content a[] {
text-decoration:none!important;
border-bottom:1px solid #4f96f6;
}
.entry-content a[]::after {
content: "\f35d";
font-family: "Font Awesome 5 Free";
margin-left: 5px;
}
消す作業
CSS
/* 画像リンクのアイコンを消す */
.entry-content a.remove-icon[] {
border:none;
}
.entry-content a.remove-icon[]::after {
content: none;
}
functions に追記 てか、js jQueryだよね。
function remove_icon() {
echo <<< EOM
<script>
//外部リンクの画像後ろのアイコンを消す
jQuery(function($){
$("a:has(img)").addClass("remove-icon");
});
</script>
EOM;
}
add_action( 'wp_footer', 'remove_icon' );