19十二/1111
在dede文章中添加随机带链接关键词
在seo中需要对文章做一些特殊的改动来加强文章的收录和质量。
今天我要在在dede文章的最后一段(也可以是随机的)加上带有链接的关键词。
具体做法是:
首先,在根目录下找到include/common.func.php文件,添加个关键的函数:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | function into_key($actile){ $keyword=array("扎金花","炸金花","诈金花","扎金花游戏大厅","同城游戏大厅下载","梭哈","梭哈游戏","梭哈游戏下载","58w同城游");//设置关键字 $keyword=" <a href='http://www.58w.cn/'>".$keyword[mt_rand(1,count($keyword)-1)]."</a>";//设置链接 $str=substr($actile,strlen('<p>')+1,strlen($str)-strlen('</p>')-2); $arr=explode('<p>',$str); //if(strstr($actile,'<strong>友情链接:'))$isb=1; //else $isb=0;$knum=''; foreach ($arr as $k => $v){ if(strstr($v,'</p>'))$arr[$k]=substr($v,0,strlen($v)-strlen('</p>')-2); //if(strstr($v,'<strong>友情链接:'))$knum=$k; } //if($isb==1&&!empty($knum))$key=$knum-1; $key=count($arr)-1; $arr[$key]=$arr[$key].$keyword; foreach ($arr as $k => $v){ $arr[$k]='<p>'.$arr[$k].'</p>'; } $str=implode('',$arr); return $str; } |
然后,在模板文件里把内容标签替换成串代码就ok了
1 | {dede:field name='id' function='into_key(@me)'/} |
如此,你以后添加的文章的最后一段都含有带链接的关键字了。
照搬这种形式,还可以在任意段落添加上相关栏目的文章等信息,使你的文章能更好的收录
例:http://www.58w.cn/a/xinwen/kexue/18247.html
2012年01月03日 12:23
Lots of beneficial in a row. I give rise to bookmarked your place.
2012年01月03日 12:30
thank you!
2012年01月05日 20:31
Hi, was just going through the google looking for good info and stumbled across your website. I am stunned at the design that you’ve on this site. It shows how you appreciate this subject.
2012年01月07日 11:18
You are welcome my blog!
2012年01月31日 20:48
为什么我测试不成功呢?语法好像有错误!!希望得到指点!!
2012年01月31日 21:51
把你的代码贴出来看看
2012年02月01日 19:06
就是用你的这个啊!!
昨天没有放对位置,今天没有错误提示了,但是当发布文章后,查看文章,发现文章内容部分是空的。只有再一次编辑后才能显示文章内容。但不显示随机标签!!
2012年02月02日 19:21
我把上面into_key函数改了一下,你在文章模板里把内容标签替换成这个 {dede:field name=’id’ function=’into_key(@me)’/} 。不用再后台文件里改了
2012年02月01日 19:12
dede/article_add.php,在大约112行,这是行的内容是什么啊?位置不同,导致的效果也不同啊?
2012年04月11日 06:19
Thanks so much for giving everyone remarkably pleasant possiblity to read from this blog. It is always so pleasurable and also stuffed with a good time for me and my office peers to visit your blog at the least 3 times in 7 days to find out the newest things you will have. And lastly, we are at all times pleased considering the fantastic knowledge you give. Some two facts in this posting are particularly the finest we have had.
2012年04月17日 19:06
cialis best price http://allmedshoponline.com/ – viagra allergic reactions