function auto_link_tags($content){
//$post_id = get_the_ID();
$post_tags = get_the_tags();
if ($post_tags) {
$i = 0;
foreach($post_tags as $tag) {
$tags[$i] = "~<(?:a\\s.*?</a>|[^>]+>)(*SKIP)(*FAIL)|\\b(?:\\b(" . $tag->name . ")\\b(?=[^>]*(<|$)))\\b~i";
$tag_url = get_tag_link($tag->term_id);
$tag_html[$i] = '<a style="color:#FF0000;" href="' . $tag_url . '" rel="tag" title="$1">$1</a>';
$i++;
}
$content = preg_replace($tags, $tag_html, $content);
}
return $content;
}Şu etiketleri otomatik linkliyor, ama yazıda 10 tane aynı kelime varsa hepsine link veriyor, her etiket için sadece 1'ine link vermesini sağlayabilecek varmı?
Her kelime'de 1 defa çalışsın, wordpress ücretli-ücretsiz yardım
3
●270
- 23-10-2015, 09:14:23Merhaba arkadaşlar,
- 23-10-2015, 10:32:30Üyeliği durduruldu
function auto_link_tags($content){ //$post_id = get_the_ID(); $post_tags = get_the_tags(); $varmi=""; if ($post_tags) { $i = 0; foreach($post_tags as $tag) { if(strstr($varmi,"($tag)") { } else { $tags[$i] = "~<(?:a\\s.*?</a>|[^>]+>)(*SKIP)(*FAIL)|\\b(?:\\b(" . $tag->name . ")\\b(?=[^>]*(<|$)))\\b~i"; $tag_url = get_tag_link($tag->term_id); $tag_html[$i] = '<a style="color:#FF0000;" href="' . $tag_url . '" rel="tag" title="$1">$1</a>'; $i++; $varmi.="($tag)"; } $content = preg_replace($tags, $tag_html, $content); } return $content; }Bu işinizi görür sanırım. - 23-10-2015, 15:40:00Çok teşekkür ederim , bu işimi çözdü.Met adlı üyeden alıntı: mesajı görüntüle
Size de teşekkür ederim.Pardon adlı üyeden alıntı: mesajı görüntüle