成都网站建设设计

将想法与焦点和您一起共享

wordpress内链 wordpress媒体库外链

如何使wordpress的标签自动变为网站文章的内链

/* 自动为文章内的标签添加内链开始 */

义马网站制作公司哪家好,找成都创新互联公司!从网页设计、网站建设、微信开发、APP开发、响应式网站建设等网站项目制作,到程序开发,运营维护。成都创新互联公司2013年至今到现在10年的时间,我们拥有了丰富的建站经验和运维经验,来保证我们的工作的顺利进行。专注于网站建设就选成都创新互联公司

$match_num_from = 1;        //一篇文章中同一个标签少于几次不自动链接

$match_num_to = 1;      //一篇文章中同一个标签最多自动链接几次

function tag_sort($a, $b){

if ( $a-name == $b-name ) return 0;

return ( strlen($a-name)  strlen($b-name) ) ? -1 : 1;

}

function tag_link($content){

global $match_num_from,$match_num_to;

$posttags = get_the_tags();

if ($posttags) {

usort($posttags, "tag_sort");

foreach($posttags as $tag) {

$link = get_tag_link($tag-term_id);

$keyword = $tag-name;

$cleankeyword = stripslashes($keyword);

$url = "a href=\"$link\" title=\"".str_replace('%s',addcslashes($cleankeyword, '$'),__('View all posts in %s'))."\"";

$url .= ' target="_blank"';

$url .= "".addcslashes($cleankeyword, '$')."/a";

$limit = rand($match_num_from,$match_num_to);

$content = preg_replace( '|(a[^]+)(.*)('.$ex_word.')(.*)(/a[^]*)|U'.$case, '$1$2%%$4$5', $content);

$content = preg_replace( '|(img)(.*?)('.$ex_word.')(.*?)()|U'.$case, '$1$2%%$4$5', $content);

$cleankeyword = preg_quote($cleankeyword,'\'');

$regEx = '\'(?!((.*?)|(a.*?)))('. $cleankeyword . ')(?!(([^]*?))|([^]*?/a))\'s' . $case;

$content = preg_replace($regEx,$url,$content,$limit);

$content = str_replace( '%%', stripslashes($ex_word), $content);

}

}

return $content;

}

add_filter('the_content','tag_link',1);

/* 自动为文章内的标签添加内链结束 */

你可以尝试一下

搜BanYuner了解更多

wordpress自动内链什么用

内链是为了增强搜索引擎的抓取,以及用户的可深度点击阅读等效果。

wordpress内链怎么设置

只需要在模板函数文件【functions.php】添加下面代码:

//自动关键词内链

$match_num_from = 1; //一个关键字少于多少不替换

$match_num_to = 5; //一个关键字最多替换

add_filter(‘the_content’,'tag_link’,1);

function tag_sort($a, $b){

if ( $a-name == $b-name ) return 0;

return ( strlen($a-name) strlen($b-name) ) ? -1 : 1;

}

function tag_link($content){

global $match_num_from,$match_num_to;

$posttags = get_the_tags();

if ($posttags) {

usort($posttags, “tag_sort”);

foreach($posttags as $tag) {

$link = get_tag_link($tag-term_id);

$keyword = $tag-name;

$cleankeyword = stripslashes($keyword);

$url = “a href=\”$link\” title=\”".str_replace(‘%s’,addcslashes($cleankeyword, ‘$’),__(‘View all posts in %s’)).”\”";

$url .= ‘ target=”_blank” class=”tag_link”‘;

$url .= “”.addcslashes($cleankeyword, ‘$’).”/a”;

$limit = rand($match_num_from,$match_num_to);

$content = preg_replace( ‘|(a[^]+)(.*)(‘.$ex_word.’)(.*)(/a[^]*)|U’.$case, ‘$1$2%%$4$5′, $content);

$content = preg_replace( ‘|(img)(.*?)(‘.$ex_word.’)(.*?)()|U’.$case, ‘$1$2%%$4$5′, $content);

$cleankeyword = preg_quote($cleankeyword,’\”);

$regEx = ‘\’(?!((.*?)|(a.*?)))(‘. $cleankeyword . ‘)(?!(([^]*?))|([^]*?/a))\’s’ . $case;

$content = preg_replace($regEx,$url,$content,$limit);

$content = str_replace( ‘%%’, stripslashes($ex_word), $content);

}

}

return $content;

}

上面代码添加到模板函数最后面 ” ?” 前方,一定要保持格式和符号不要更改,然后更新模板函数,清除浏览器缓存后重新打开一个文章页面就会看的到效果了。

wordpress插件有哪些?

不能不说,wordpress确实是全球最适合博客群发的程序,但是,其seo方面的优秀却不是来自于程序本身,而是来自众多的wordpress使用者,正是他们开发的数量众多的wordpress SEO插件,让让我们的wordpress在seo领域里能够傲视群雄!\x0d\x0a\x0d\x0a作为一个使用了数年wordpress的忠实粉丝,嗯,也就是我啦,今天便来与大家分享一下wordpress SEO优化中不可不使用的插件!\x0d\x0a\x0d\x0a1,Akismet\x0d\x0a\x0d\x0a啥?Akismet,看到这个插件,你可能要吼起来了,啥,你懂不懂?这个哪是什么seo插件,这是个防垃圾留言的插件!\x0d\x0a\x0d\x0a是的,这确实是防垃圾留言的插件,但是,它也具有很强大的seo功能——搜索引擎对充满了大量垃圾留言的站点的态度就是杀,想想吧,如果一个网站连垃圾网站都没时间清理,这个网站一定没有人打理,不是个垃圾站就是个死站!\x0d\x0a\x0d\x0a2,Google XML Sitemaps\x0d\x0a\x0d\x0a向谷歌提交sitemaps的插件,帮助网站被更好的收录!\x0d\x0a\x0d\x0a3,Platinum SEO Pack\x0d\x0a\x0d\x0a跟All in one seo packs一个类型,但功能更强大,很多人都说All in one seo packs已经过时了,但是,按我个人的使用经历来说,Platinum SEO Pack还是非常强大,非常适合wordpress的!\x0d\x0a\x0d\x0a4, SEO Friendly Images\x0d\x0a\x0d\x0a这个是干嘛的?简单的说,就是给图片添加title的,呵呵,全自动的哦!\x0d\x0a\x0d\x0a5,Simple Tags\x0d\x0a\x0d\x0aTAG优化的利器,推荐使用!\x0d\x0a\x0d\x0a6,cos-html-cache\x0d\x0a\x0d\x0a拥有这个,你的博客将不再是伪静态了,而是真正的html文件,更符合蜘蛛的口味,而且,能够有效减轻服务器压力!\x0d\x0a\x0d\x0a7,Baidu Sitemap Generator\x0d\x0a\x0d\x0a生成百度 Sitemap XML 文件,就相当于网站被百度--全球最大的中文搜索引擎订阅,进而为您的网站带来潜在的流量,同时生成一个静态的站点地图页面,对所有的搜索引擎都有利。\x0d\x0a\x0d\x0a8,WP Keyword Link\x0d\x0a\x0d\x0a最重头的插件来了,WP Keyword Link为你的wordpress博客添加关键词的链接,更多的内链和外链,更好的SEO! 给文章加上内部链接有利于增加搜索引擎收录。\x0d\x0a\x0d\x0a好吧,如果你安装了以上的seo插件的话,你wordpress程序的seo优化工作已经差不多了,剩下的就看你怎么做文章写作以及外链建设了!


文章题目:wordpress内链 wordpress媒体库外链
URL地址:http://chengdu.cdxwcx.cn/article/dopijos.html