为了有助于网站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工作流
3d卡通风格多彩头发的女人
树上站着一只鸟ComfyUI工作流
海中一头鲸鱼ComfyUI工作流
一只可爱的猫骑着一匹可爱的马ComfyUI工作流
一艘来自工业时代的飞船ComfyUI工作流
一个神秘的隐藏面孔下一本书的剪影ComfyUI工作流
森林里一只空灵的犀鸟ComfyUI工作流
猜你喜欢
声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!

会议人员60s签到倒计时插件
在线生成金属文字
canvas空间文本射线
纯css翻书效果
用svg画出游泳池动画效果
js实现下雪特效
css3搭积木叠加图形
SVG路径动画效果










