首页 > CMS > Wordpress > 正文

wodpress博客的评论外链加上跳转的方法

2024-09-07 00:52:21
字体:大 中 小
来源:转载
供稿:网友

wodpress博客的评论外链已经是许多博主不可接受的一种程度了,我们下面来给各位介绍一篇把外连通过修改成跳转的连接了,这样不会影响到网站权重了.

昨天的时候修改了一下博客的评论里的外链,有外链转内链,折腾了一下博客,看看效果还行,下面分享一下.

模板function.php添加下面的代码:

  1. /**博客的评论里的外链转内链**/ 
  2. add_filter('get_comment_author_link','add_redirect_comment_link', 5); 
  3. add_filter('comment_text', 'add_redirect_comment_link', 99); 
  4. function add_redirect_comment_link($text= ''){ 
  5.   $text=str_replace('href="','href="'.get_option('home').'/goto.php?url=', $text); 
  6.   $text=str_replace("href='","href='".get_option('home')."/goto.php?url=", $text); //Vevb.com 
  7.   return$text; 
  8. } 

上面的代码其实就是把页面显示的链接都修改成http://www.Vevb.com/goto.php?url=【网站链接】

新建goto.php,放到跟目录下.

  1. <!doctype html> 
  2. <html lang="en"> 
  3. <head> 
  4. <meta charset="UTF-8"> 
  5. <meta name="Author" content=""> 
  6. <meta name="Keywords" content=""> 
  7. <meta name="Description" content=""> 
  8. <meta name="robots"content="noindex,nofollow"> 
  9.  
  10. <meta http-equiv="refresh"content="3;url=<?php $url=$_GET['url']; echo htmlspecialchars($url);?>"> 
  11. <title>跳转页面</title> 
  12. <style> 
  13. .spinner { 
  14. margin: 100px auto 0; 
  15. width: 150px; 
  16. text-align: center; 
  17. } 
  18.  
  19. .spinner > div { 
  20. width: 30px; 
  21. height: 30px; 
  22.  
  23.  
  24. border-radius: 100%; 
  25. display: inline-block; 
  26. -webkit-animation: bouncedelay 1.4s infinite ease-in-out; 
  27. animation: bouncedelay 1.4s infinite ease-in-out; 
  28. /* Prevent first frame from flickering when animation starts */ 
  29. -webkit-animation-fill-mode: both; 
  30. animation-fill-mode: both; 
  31. } 
  32.  
  33. .spinner .bounce1 { 
  34. -webkit-animation-delay: -0.32s; 
  35. animation-delay: -0.32s; 
  36. background-color: #428bca; 
  37. } 
  38.  
  39. .spinner .bounce2 { 
  40. -webkit-animation-delay: -0.16s; 
  41. animation-delay: -0.16s; 
  42. background-color: #Dd534F; 
  43. } 
  44.  
  45. .spinner .bounce3 { 
  46. -webkit-animation-delay: -0.01s; 
  47. animation-delay: -0.01s; 
  48. background-color: #67CF22; 
  49. } 
  50.  
  51. @-webkit-keyframes bouncedelay { 
  52. 0%, 80%, 100% { -webkit-transform: scale(0.0) } 
  53. 40% { -webkit-transform: scale(1.0) } 
  54. } 
  55.  
  56. @keyframes bouncedelay { 
  57. 0%, 80%, 100% { 
  58. transform: scale(0.0); 
  59. -webkit-transform: scale(0.0); 
  60. } 40% { 
  61. transform: scale(1.0); 
  62. -webkit-transform: scale(1.0); 
  63. } 
  64. } 
  65. </style> 
  66. </head> 
  67. <body> 
  68. <div class="spinner"> 
  69. <div class="bounce1"></div> 
  70. <div class="bounce2"></div> 
  71. <div class="bounce3"></div> 
  72. </div> 
  73. </body> 
  74. </html> 

搞定了,有问题请留言.

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表