萬千wp主題中,我選中了欲思主題。
安裝啟用之後,便開始了我的頁面改造。
啟用連結功能
欲思主題默認是沒有友情連結這一小工具的,同時WorldPress自帶的連結功能被隱藏了,所以我們要將其顯現。
將下列代碼添加到你所使用的主題的 functions.php
//連結 add_filter('pre_option_link_manager_enabled','__return_true');
添加好以後,在你的後臺左側連結便顯現了,同時在外觀小工具裡也有了連結小工具,你可以將其用作友情連結啦。
添加go頁面跳轉
很多博客都會使用這樣的外部連結跳轉提示頁面,這樣做有利於seo,對搜尋引擎更加友好。
下列代碼來自網絡:
代碼請前往 linjianming.com 獲取 將上面代碼複製並保存為一個 index.php 文件丟到網站根目錄的 go 文件夾下。到此已經可以實現外鏈跳轉提示了。
但是文章內和評論內的外鏈無法跳轉提示,我們可通過在你所使用的主題的 functions.php 文件中添加如下代碼實現:
//文章內外鏈添加go跳轉 function the_content_nofollow($content){ preg_match_all('/<a(.*?)href="(.*?)"(.*?)>/',$content,$matches); if($matches){ foreach($matches[2] as $val){ if(strpos($val,'://')!==false && strpos($val,home_url())===false && !preg_match('/\.(jpg|jepg|png|ico|bmp|gif|tiff)/i',$val)){ $content=str_replace("href=\"$val\"", "href=\"".home_url()."/go/?url=$val\" ",$content); } } } return $content; } add_filter('the_content','the_content_nofollow',999);//評論者連結添加go跳轉 function add_redirect_comment_link($text = ''){ $text=str_replace('href="', 'href="'.get_option('home').'/go/?url=', $text); return $text; } add_filter('get_comment_author_link', 'add_redirect_comment_link', 5); add_filter('comment_text', 'add_redirect_comment_link', 99);
去除url中的category
一般我們新建了一個分類以後,比如 python,默認的url會顯示為 http://你的域名/category/python,但據說這樣不利於seo,因此推薦一個插件來將url改為 http://你的域名/python。
插件名:No Category Base (WPML)