涓篧ordPress娣诲姞鍒嗙被銆佹爣绛捐嚜瀹氫箟鏍囬

  • A+
鎵灞炲垎绫伙細wordpress
鎽樿

涓篧ordPress鍒嗙被銆佹爣绛炬坊鍔犺嚜瀹氫箟鐨勫ソ澶勫湪浜庡彲浠ュ仛缃戠珯鐨勬悳绱㈠紩鎿庝紭鍖栵紙鏈夊埄浜嶹ordPress SEO锛夛紝鍙堝彲浠ユ彁鍗囩敤鎴蜂綋楠屻

涓篧ordPress娣诲姞鍒嗙被銆佹爣绛捐嚜瀹氫箟鏍囬鏈変粈涔堝ソ澶勶紵濂藉鍦ㄤ簬鍙互鍋氱綉绔欑殑鎼滅储寮曟搸浼樺寲锛堟湁鍒╀簬WordPress SEO锛夛紝鍙堝彲浠ユ彁鍗囩敤鎴蜂綋楠屻傚鏋滀笉浣跨敤鑷畾涔夋爣棰樼殑璇濓紝鍗虫枃绔犵殑鏍囬鍗充负缃戦〉鎼滅储寮曟搸鎶撳彇鐨勬爣棰橈紝鍒嗙被鏍囬锛岄渶瑕佺畝鐭竴鐐癸紝鍚﹀垯鐢ㄦ埛鎵撳紑鍒嗙被鐩綍鏃朵細鏄惧緱寰堟贩涔便

浠庢悳绱㈠紩鎿庝紭鍖栬搴︽潵璇达紝杩欐牱绠鐭殑鏍囬涔熸病鏈変粈涔堜笉濂斤紝浣嗘槸锛屼粠鏁翠綋涓婃潵璇达紝骞舵病鏈夊缃戠珯杩涜濂界殑鎼滅储寮曟搸浼樺寲銆傝屼负WordPress閲囩敤鑷畾涔夋爣棰樼殑鏂瑰紡锛屽彲浠ラ傚綋澧炲姞鍏抽敭璇嶇殑鏍囬锛屾棦鑳藉惛寮曠敤鎴凤紝鍙堣兘瀵规悳绱㈠紩鎿庡睍鐜拌壇濂姐

缁忚繃涓鐣悳绱㈠拰鎽哥储锛屼互鍙婇槄璇 WordPress 鏂囨。锛屾荤畻鏄壘鍒颁簡瑙e喅鍔炴硶銆傚湪杩欓噷锛屼笉寰椾笉璇翠竴涓嬶紝鎶鏈х殑闂锛屼竴瀹氳璁板緱璋锋瓕锛岃浣忥細璋锋瓕锛佸緢鏃╀箣鍓嶇敤搴﹀鏌ユ壘锛屾敹鑾蜂笉澶э紝褰撶劧锛屽苟涓嶆槸璇存病鏈夊弬鑰冧环鍊硷紝浣嗘槸鍗寸浉瀵硅灏忋傜敤璋锋瓕锛岃繖涓棶棰樺緢蹇鎴戞壘鍒颁簡鏂规銆

涓篧ordPress娣诲姞鍒嗙被銆佹爣绛捐嚜瀹氫箟鏍囬

涓篧ordPress娣诲姞鍒嗙被銆佹爣绛捐嚜瀹氫箟鏍囬

涓篧ordPress娣诲姞鍒嗙被銆佹爣绛捐嚜瀹氫箟鏍囬鐨勫疄鐜版柟娉曪細

1銆佹妸涓嬮潰鐨勪唬鐮佷繚瀛樺鍒舵垚涓涓狿HP鏂囦欢锛屾瘮濡傦細title.php

  1. <?php
  2. //鑷畾涔夊垎绫绘爣棰
  3. class聽zm_wp_title{
  4. 聽聽聽聽function聽__construct(){
  5. 聽聽聽聽//聽鍒嗙被
  6. 聽聽聽聽聽聽聽聽add_action(聽'category_add_form_fields',聽array(聽$this,聽'add_tax_title_field'聽)聽);
  7. 聽聽聽聽聽聽聽聽add_action(聽'category_edit_form_fields',聽array(聽$this,聽'edit_tax_title_field'聽)聽);
  8. 聽聽聽聽聽聽聽聽add_action(聽'edited_category',聽array(聽$this,聽'save_tax_meta'聽),聽10,聽2聽);
  9. 聽聽聽聽聽聽聽聽add_action(聽'create_category',聽array(聽$this,聽'save_tax_meta'聽),聽10,聽2聽);
  10. 聽聽聽聽//聽鏍囩
  11. 聽聽聽聽聽聽聽聽add_action(聽'post_tag_add_form_fields',聽array(聽$this,聽'add_tax_title_field'聽)聽);
  12. 聽聽聽聽聽聽聽聽add_action(聽'post_tag_edit_form_fields',聽array(聽$this,聽'edit_tax_title_field'聽)聽);
  13. 聽聽聽聽聽聽聽聽add_action(聽'edited_post_tag',聽array(聽$this,聽'save_tax_meta'聽),聽10,聽2聽);
  14. 聽聽聽聽聽聽聽聽add_action(聽'create_post_tag',聽array(聽$this,聽'save_tax_meta'聽),聽10,聽2聽);
  15. 聽聽聽聽}
  16. 聽聽聽聽publicfunction聽add_tax_title_field(){
  17. ?>
  18. 聽聽聽聽聽聽聽聽<div聽class="form-field聽term-title-wrap">
  19. 聽聽聽聽聽聽聽聽聽聽聽聽<label聽for="term_meta[tax_zm_title]">鑷畾涔夋爣棰</label>
  20. 聽聽聽聽聽聽聽聽聽聽聽聽<input聽type="text"聽name="term_meta[tax_zm_title]"聽id="term_meta[tax_zm_title]"聽value=""聽/>
  21. 聽聽聽聽聽聽聽聽聽聽聽聽<p聽class="description">鎼滅储寮曟搸浼樺寲鑷畾涔夋爣棰橈紝涓嶅~鍐欏嵆涓洪粯璁ゆ爣棰</p>
  22. 聽聽聽聽聽聽聽聽</div>
  23. <?php
  24. 聽聽聽聽}聽//聽add_tax_title_field
  25. 聽聽聽聽publicfunction聽edit_tax_title_field(聽$term聽){
  26. 聽聽聽聽聽聽聽聽$term_id聽=聽$term->term_id;
  27. 聽聽聽聽聽聽聽聽$term_meta聽=聽get_option(聽"zm_taxonomy_$term_id"聽);
  28. 聽聽聽聽聽聽聽聽$zm_title聽=聽$term_meta['tax_zm_title']聽?聽$term_meta['tax_zm_title']聽:聽'';
  29. ?>
  30. 聽聽聽聽聽聽聽聽<tr聽class="form-field聽term-title-wrap">
  31. 聽聽聽聽聽聽聽聽聽聽聽聽<th聽scope="row">
  32. 聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽<label聽for="term_meta[tax_zm_title]">鑷畾涔夋爣棰</label>
  33. 聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽<td>
  34. 聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽<input聽type="text"聽name="term_meta[tax_zm_title]"聽id="term_meta[tax_zm_title]"聽value="<?php聽echo聽$zm_title;聽?>"聽/>
  35. 聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽<p聽class="description">鎼滅储寮曟搸浼樺寲鑷畾涔夋爣棰橈紝涓嶅~鍐欏嵆涓洪粯璁ゆ爣棰</p>
  36. 聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽</td>
  37. 聽聽聽聽聽聽聽聽聽聽聽聽</th>
  38. 聽聽聽聽聽聽聽聽</tr>
  39. <?php
  40. 聽聽聽聽}聽//聽edit_tax_title_field
  41. 聽聽聽聽publicfunction聽save_tax_meta(聽$term_id聽){
  42. 聽聽聽聽聽聽聽聽if聽(聽isset(聽$_POST['term_meta']聽)聽)聽{
  43. 聽聽聽聽聽聽聽聽聽聽聽聽$t_id聽=聽$term_id;
  44. 聽聽聽聽聽聽聽聽聽聽聽聽$term_meta聽=聽array();
  45. 聽聽聽聽聽聽聽聽聽聽聽聽$term_meta['tax_zm_title']聽=聽isset聽(聽$_POST['term_meta']['tax_zm_title']聽)聽?聽$_POST['term_meta']['tax_zm_title']聽:聽'';
  46. 聽聽聽聽聽聽聽聽聽聽聽聽update_option(聽"zm_taxonomy_$t_id",聽$term_meta聽);
  47. 聽聽聽聽聽聽聽聽}聽//聽if聽isset(聽$_POST['term_meta']聽)
  48. 聽聽聽聽}聽//聽save_tax_meta
  49. }聽//聽zm_wp_title
  50. $wptt_tax_title聽=聽new聽zm_wp_title();
  51. function聽the_zm_title()聽{
  52. 聽聽聽聽$category聽=聽get_the_category();
  53. 聽聽聽聽$term_id聽=聽$category[0]->cat_ID;
  54. 聽聽聽聽$term_meta聽=聽get_option(聽"zm_taxonomy_$term_id"聽);
  55. 聽聽聽聽$tax_zm_title聽=聽$term_meta['tax_zm_title']聽?聽$term_meta['tax_zm_title']聽:聽'';
  56. 聽聽聽聽echo$tax_zm_title;
  57. }
  58. function聽get_current_tag_id()聽{
  59. 聽聽聽聽$current_tag聽=聽single_tag_title('',聽false);
  60. 聽聽聽聽$tags聽=聽get_tags();
  61. 聽聽聽聽foreach($tagsas$tag)聽{
  62. 聽聽聽聽聽聽聽聽if($tag->name聽==聽$current_tag)聽return$tag->term_id;
  63. 聽聽聽聽}
  64. }
  65. function聽zm_tag_title()聽{
  66. 聽聽聽聽$term_id聽=聽get_current_tag_id();
  67. 聽聽聽聽$term_meta聽=聽get_option(聽"zm_taxonomy_$term_id"聽);
  68. 聽聽聽聽$zm_tag_title聽=聽$term_meta['tax_zm_title']聽?聽$term_meta['tax_zm_title']聽:聽'';
  69. 聽聽聽聽echo$zm_tag_title;
  70. }
  71. ?>

2銆佹妸 title.php 鏂囦欢寮曞叆鍒颁富棰樺嚱鏁癴unctions.php涓

  1. //鑷畾涔夋爣棰
  2. require聽get_template_directory()聽.聽'/title.php';

瀹屾垚涓婇潰鐨勬楠や箣鍚庯紝鍩烘湰涓婂悗鍙板氨宸茬粡鍑虹幇浜嗗垎绫汇佹爣绛捐嚜瀹氫箟鏍囬濉啓妗嗭紝鎺ヤ笅鏉ラ渶瑕佸仛鐨勫氨鏄墠鍙扮殑璋冪敤銆

3銆佹妸涓嬮潰鐨勪唬鐮佹斁鍒拌嚜瀹氫箟 Title 涓 锛岃繖涓渶瑕佹牴鎹富棰樻儏鍐点

鍒嗙被鏍囬锛

  1. <?php聽if聽(聽is_category()聽)聽{聽?><title><?php聽$title聽=聽the_zm_title();聽echo聽($title)聽?聽''.$title.''聽:聽single_cat_title();聽?>聽-聽<?php聽bloginfo('name');聽?></title><?php聽}聽?>

鏍囩鏍囬锛

  1. <?php聽if聽(聽is_tag()聽)聽{聽?><title><?php聽聽$title聽=聽zm_tag_title();聽echo聽($title)聽?聽''.$title.''聽:聽single_tag_title("",聽true);聽?>聽-聽<?php聽bloginfo('name');聽?></title><?php聽}聽?>

闈炲父绠鍗曪紝灏辨槸鍒ゆ柇鑷畾涔夋爣棰樻湁娌℃湁杈撳叆锛屽鏋滄病鏈夌殑璇濓紝鍗虫樉绀哄師鏍囬锛屽鏋滄湁鑷畾涔夋爣棰橈紝鍒欐樉绀鸿嚜瀹氫箟鏍囬銆

鏂囩珷鏉ユ簮浜庯細WPGeek WordPress锛堝井淇″彿锛

avatar

鍙戣〃璇勮

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

鐩墠璇勮锛6   鍏朵腑锛氳瀹  5   鍗氫富  1

    • avatar 鎲ф啲Licoy 0

      涓嶇煡鍗氫富鏄惁鐭ラ亾濡備綍鑷畾涔夋暟鎹簱瀛楁鎴栬〃

      • avatar 寮犳旦娴 0

        瀛︿範浜嗭紝鎰熻阿鍗氫富鍒嗕韩銆

        • avatar 骞虫闈掍簯 0

          寮卞急鐨勯棶涓涓嬬涓夋鎬庝箞娣诲姞鍒颁富棰樹腑

            • avatar 鍗曡Е瑙掕殏铓 Admin

              @骞虫闈掍簯 闇瑕佹牴鎹富棰楾itle鐨勪綅缃坊鍔爚

                • avatar LEO 0

                  @鍗曡Е瑙掕殏铓 鎶辨瓑鎴戞兂闂竴涓嬬涓夋楠ゆ垜娣诲姞鍒皌itle閲岄潰锛屾樉绀轰笉姝g‘锛岃嚜宸辨妧鏈湁闄愶紝浣嗘槸鐗瑰埆鎯宠杩欎釜鍔熻兘銆傛垜鐢ㄧ殑澶у墠绔殑D8涓婚锛岃瘯浜嗕竴涓櫄涓婁簡锛岃繕鏄病寮勫ソ銆

              • avatar 鑰愯厫铓娉 0

                浜叉祴鍙敤锛屽凡璋冩暣銆傝阿璋㈠崥涓伙紒