为了有助于网站seo,typecho如何直接替换文章内容的友链,直接附代码:
$Keywordspress = new Typecho_Widget_Helper_Form_Element_Textarea('Keywordspress', NULL, NULL, _t('关键字内链'), _t('每行1组以"关键词|(半角竖线)链接"形式填写)'));
$form->addInput($Keywordspress);
/**
* 文章内容替换为内链
*/
function get_glo_keywords($content){
$settings = Helper::options()->Keywordspress;
$keywords_list = array();
if (strpos($settings,'|')) {
//解析关键词数组
$kwsets = array_filter(preg_split("/(\r|\n|\r\n)/",$settings));
foreach ($kwsets as $kwset) {
$keywords_list[] = explode('|',$kwset);
}
}
ksort($keywords_list); //对关键词排序,短词排在前面
if($keywords_list){
$readnum = 0;
$i = 0;
$j = 1;
foreach ($keywords_list as $key => $val) {
$title = $val[$i];
$len = strlen($title);
$str = '<a href="'.$val[$j].'" target="_blank">@'.$title.'</a>';
$str_index = mb_strpos($content, $title);
$content = preg_replace('/(?!<[^>]*)'.$title.'(?![^<]*>)/',$str,$content,1);
if(is_numeric($str_index)){
$readnum += 1;
//$content = substr_replace($content,$str,$str_index,$len);
//$content = $this->str_replace_limit($title,$str,$content,$this->limit);
}
if($readnum == 8) {
return $content; //匹配到8个关键词就退出
$i += 2;
$j += 2;
}
}
}
return $content;
}
上面是“typecho如何替换文章内容的友链”的全面内容,想了解更多关于 seo教程 内容,请继续关注web建站教程。
当前网址:https://ipkd.cn/webs_2072.html
workflows工作流
一个孤独的斗篷人物站在一座巨大的雕塑旁
一个超现实和超现实的场景,在森林中心有一座蛇形的房子
葡萄庄园白葡萄酒ComfyUI工作流
城市里出现一只可爱的小生物ComfyUI工作流
一尊白玉佛像ComfyUI工作流
一颗巨型的木星ComfyUI工作流
一个闪闪发光的金属球ComfyUI工作流
小丑鱼马林在鱼缸里游来游去ComfyUI工作流
猜你喜欢
声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!

在线生成金属文字
利用CSS3做一个星级评分样式
canvas空间文本射线
自动打字效果(惊喜在后面)
利用js做一个炫酷音乐背景效果
css3动画loading效果
3d文字360度旋转
css3绘制一个会动的大嘴鸟










