﻿{"id":598,"date":"2014-09-03T15:50:36","date_gmt":"2014-09-03T07:50:36","guid":{"rendered":"http:\/\/www.wuhaibin.com\/blog\/?p=598"},"modified":"2014-09-03T15:50:36","modified_gmt":"2014-09-03T07:50:36","slug":"wordpress-add_theme_support-%e5%87%bd%e6%95%b0%e8%af%a6%e8%a7%a3","status":"publish","type":"post","link":"http:\/\/www.wuhaibin.com\/blog\/work\/wordpress\/598.html","title":{"rendered":"WordPress add_theme_support() \u51fd\u6570\u8be6\u89e3"},"content":{"rendered":"<p style=\"color: #000000;\"><span class='wp_keywordlink_affiliate'><a href=\"http:\/\/www.wuhaibin.com\/blog\/category\/work\/wordpress\" title=\"WordPress\" rel=\"nofollow\" target=\"_blank\">WordPress<\/a><\/span> \u662f\u4e00\u4e2a\u4f18\u79c0\u7684\u6587\u7ae0\u7ba1\u7406\u7cfb\u7edf\uff0c\u4e5f\u662f\u4e00\u4e2a\u4f18\u79c0\u7684\u3001\u64cd\u63a7\u6027\u826f\u597d\u7684 CMS \u6846\u67b6\uff0c\u4e0d\u5f97\u4e0d\u627f\u8ba4\u5176\u4e00\u4e9b\u529f\u80fd\u8bbe\u7f6e\u7684\u8ba9\u6211\u8fd9\u79cd\u61d2\u4eba\u5b9e\u5728\u662f\u627e\u4e0d\u51fa\u7406\u7531\u4e0d\u61d2\uff0c WP \u4e2d\u7684\u4e00\u4e9b\u529f\u80fd\u5df2\u7ecf\u901a\u8fc7\u5185\u7f6e\u7684\u4e00\u4e9b\u51fd\u6570\u6a21\u5757\u5316\u4e86\uff0c\u5c31\u50cf<strong>add_theme_support()\u00a0<\/strong>\u8fd9\u4e2a\u51fd\u6570\uff0c\u6211\u4eec\u5728\u505a\u4e3b\u9898\u7684\u65f6\u5019\u53ea\u8981\u7b80\u5355\u7684\u6dfb\u52a0\u51e0\u4e2a\u53c2\u6570\uff0c\u4e0d\u518d\u7528\u590d\u6742\u7684\u4ee3\u7801\uff0c\u5c31\u80fd\u5b9e\u73b0\u5f3a\u5927\u7684\u529f\u80fd\u3002<br \/>\n<span id=\"more-784\"><\/span><br \/>\n\u5f88\u9057\u61be\uff0c\u76f4\u81f3\u76ee\u524d\u4e3a\u6b62\uff0c\u8fd9\u4e48\u91cd\u8981\u7684\u4e00\u4e2a\u51fd\u6570\u8fd8\u6ca1\u6709\u4e00\u7bc7\u6bd4\u8f83\u5168\u9762\u7684\u4e2d\u6587\u6587\u7ae0\u53bb\u4ecb\u7ecd\uff0c\u5728\u7f51\u4e0a\u8c37\u6b4c\u3001\u767e\u5ea6\u4e86\u4e00\u756a\uff0c\u7ecf\u8fc7\u4eb2\u8eab\u4f53\u9a8c\uff0c\u7ffb\u8bd1\u3001\u603b\u7ed3\u3001\u6574\u7406\u5982\u4e0b\uff0c\u4e2a\u4eba\u611f\u89c9\u76ee\u524d\u4e3a\u6b62\u8fd8\u7b97\u662f\u6bd4\u8f83\u5168\u9762\u7684\u4e86\u3002<\/p>\n<h3 style=\"color: #4f9d9d;\">\u51fd\u6570\u63cf\u8ff0<\/h3>\n<p style=\"color: #000000;\">\u5141\u8bb8 <span class='wp_keywordlink_affiliate'><a href=\"http:\/\/www.wuhaibin.com\/blog\/category\/work\/wordpress\" title=\"WordPress\" rel=\"nofollow\" target=\"_blank\">WordPress<\/a><\/span> \u4e3b\u9898\u6216\u63d2\u4ef6 \u7ed9\u5f53\u524d\u6b63\u5728\u4f7f\u7528\u7684\u4e3b\u9898\u6ce8\u518c\u4e00\u4e9b\u7279\u8272\u529f\u80fd\uff0c\u5982\u679c\u5728\u4e3b\u9898\u4e2d\u4f7f\u7528\uff0c\u5e94\u8be5\u5c06\u8be5\u51fd\u6570\u5199\u5165 function.php \u6587\u4ef6\u4e2d\uff0c\u5982\u679c\u662f\u5728\u63d2\u4ef6\u4e2d\u4f7f\u7528\u8be5\u51fd\u6570\uff0c\u90a3\u5b83\u5fc5\u987b\u6302\u5728\u94a9\u5b50\u4e0a\uff08HOOK\uff09\uff0c\u5982\u679c\u662f\u6302\u5728\u94a9\u5b50\u4e0a\uff0c\u90a3\u4ed6\u5fc5\u987b\u6302\u5728\u201dafter_setup_theme\u201d\u94a9\u5b50\u4e0a\uff0c\u5982\u679c\u662f\u5728init\u7cfb\u5217\u4e0a\u5c06\u4f1a\u592a\u665a\uff0c\u4ee5\u81f4\u90e8\u5206\u7279\u8272\u529f\u80fd\u5c06\u5931\u6548\u3002<br \/>\n\u5927\u6982\u89e3\u91ca\u5c31\u662f\u8fd9\u6837\uff0c\u795e\u554a\uff0c\u539f\u8c05\u6211\u90a3\u5351\u5fae\u7684\u82f1\u6587\u548c\u5351\u52a3\u7684\u4e2d\u6587\u8bed\u6cd5\u5427\u3002<\/p>\n<h3 style=\"color: #4f9d9d;\">\u4f7f\u7528\u65b9\u6cd5<\/h3>\n<p style=\"color: #000000;\">\n<div class=\"wp_syntax\" style=\"color: #110000;\">\n<table>\n<tbody>\n<tr>\n<td class=\"code\" style=\"color: #333333;\">\n<pre class=\"php\"><span style=\"font-weight: bold; color: #000000;\">&lt;?php<\/span> add_theme_support<span style=\"color: #009900;\">(<\/span> <span style=\"color: #000088;\">$feature<\/span> <span style=\"color: #009900;\">)<\/span><span style=\"color: #339933;\">;<\/span> <span style=\"font-weight: bold; color: #000000;\">?&gt;<\/span><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p style=\"color: #000000;\">\n<h3 style=\"color: #4f9d9d;\">\u53c2\u6570\u3001\u53d8\u91cf<\/h3>\n<p style=\"color: #000000;\">\u53ef\u4f9b $feature \u53d8\u91cf\u4f7f\u7528\u7684\u53c2\u6570\u6709\u4ee5\u4e0b5\u4e2a\u3002<\/p>\n<ol style=\"color: #000000;\">\n<li>\u2018post-thumbnails\u2019 \u2014\u2013 \u589e\u52a0\u7f29\u7565\u56fe\u652f\u6301<\/li>\n<li>automatic-feed-links\u2019 \u81ea\u52a8\u8f93\u51faRSS<\/li>\n<li>\u2018post-formats\u2019\u2014\u2013 \u589e\u52a0\u6587\u7ae0\u683c\u5f0f\u529f\u80fd<\/li>\n<li>\u2018custom-background\u2019\u2014\u2013 \u589e\u52a0\u81ea\u5b9a\u4e49\u80cc\u666f<\/li>\n<li>\u2018custom-header\u2019\u2014\u2013 \u589e\u52a0\u81ea\u5b9a\u4e49\u9876\u90e8\u56fe\u50cf<\/li>\n<\/ol>\n<p style=\"color: #000000;\">\u4e5f\u5c31\u662f\u8bf4\u4f60\u53ef\u4ee5\u50cf\u5982\u4e0b\u90a3\u6837\u4f7f\u7528<br \/>\n<code><\/code><\/p>\n<div class=\"wp_syntax\" style=\"color: #110000;\">\n<table>\n<tbody>\n<tr>\n<td class=\"code\" style=\"color: #333333;\">\n<pre class=\"php\">add_theme_support<span style=\"color: #009900;\">(<\/span> <span style=\"color: #0000ff;\">'post-thumbnails'<\/span> <span style=\"color: #009900;\">)<\/span><span style=\"color: #339933;\">;<\/span>\r\nadd_theme_support<span style=\"color: #009900;\">(<\/span> <span style=\"color: #0000ff;\">'automatic-feed-links'<\/span> <span style=\"color: #009900;\">)<\/span><span style=\"color: #339933;\">;<\/span>\r\nadd_theme_support<span style=\"color: #009900;\">(<\/span> <span style=\"color: #0000ff;\">'post-formats'<\/span><span style=\"color: #339933;\">,<\/span> <span style=\"color: #990000;\">array<\/span><span style=\"color: #009900;\">(<\/span> <span style=\"color: #0000ff;\">'aside'<\/span><span style=\"color: #339933;\">,<\/span> <span style=\"color: #0000ff;\">'gallery'<\/span> <span style=\"color: #009900;\">)<\/span> <span style=\"color: #009900;\">)<\/span><span style=\"color: #339933;\">;<\/span>\r\nadd_theme_support<span style=\"color: #009900;\">(<\/span> <span style=\"color: #0000ff;\">'custom-background'<\/span> <span style=\"color: #009900;\">)<\/span><span style=\"color: #339933;\">;<\/span>\r\nadd_theme_support<span style=\"color: #009900;\">(<\/span> <span style=\"color: #0000ff;\">'custom-header'<\/span> <span style=\"color: #009900;\">)<\/span><span style=\"color: #339933;\">;<\/span><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p style=\"color: #000000;\">\n<h3 style=\"color: #4f9d9d;\">\u7279\u522b\u7528\u6cd5<\/h3>\n<p style=\"color: #000000;\">\u9700\u8981\u6307\u51fa\u7684\u662f\uff0c\u5728 Wp 2.9 \u7248\u672c\u540e\uff0c\u6211\u4eec\u53ef\u4ee5\u7ed9 \u2018post-thumbnails\u2019 \u5373\u7f29\u7565\u56fe\u529f\u80fd\u589e\u52a0\u4e00\u4e2a\u9650\u5b9a\u7684\u53c2\u6570\uff0c\u4e3e\u4f8b\u5982\u4e0b\uff1a<br \/>\n<code><\/code><\/p>\n<div class=\"wp_syntax\" style=\"color: #110000;\">\n<table>\n<tbody>\n<tr>\n<td class=\"code\" style=\"color: #333333;\">\n<pre class=\"php\"><span style=\"font-style: italic; color: #666666;\">\/\/\u5e38\u89c4\u7528\u6cd5\uff0c\u5728\u6240\u6709\u6837\u5f0f\u7684\u6587\u7ae0\u3001\u9875\u9762\u4e2d\u4f7f\u7528\u7f29\u7565\u56fe\u529f\u80fd<\/span>\r\nadd_theme_support<span style=\"color: #009900;\">(<\/span> <span style=\"color: #0000ff;\">'post-thumbnails'<\/span> <span style=\"color: #009900;\">)<\/span><span style=\"color: #339933;\">;<\/span>\r\n<span style=\"font-style: italic; color: #666666;\">\/\/\u4ec5\u5728post\u4e2d\u4f7f\u7528\u7f29\u7565\u56fe\u529f\u80fd<\/span>\r\nadd_theme_support<span style=\"color: #009900;\">(<\/span> <span style=\"color: #0000ff;\">'post-thumbnails'<\/span><span style=\"color: #339933;\">,<\/span> <span style=\"color: #990000;\">array<\/span><span style=\"color: #009900;\">(<\/span> <span style=\"color: #0000ff;\">'post'<\/span> <span style=\"color: #009900;\">)<\/span> <span style=\"color: #009900;\">)<\/span><span style=\"color: #339933;\">;<\/span>         \r\n<span style=\"font-style: italic; color: #666666;\">\/\/\u4ec5\u5728page\u4e2d\u4f7f\u7528\u7f29\u7565\u56fe\u529f\u80fd<\/span>\r\nadd_theme_support<span style=\"color: #009900;\">(<\/span> <span style=\"color: #0000ff;\">'post-thumbnails'<\/span><span style=\"color: #339933;\">,<\/span> <span style=\"color: #990000;\">array<\/span><span style=\"color: #009900;\">(<\/span> <span style=\"color: #0000ff;\">'page'<\/span> <span style=\"color: #009900;\">)<\/span> <span style=\"color: #009900;\">)<\/span><span style=\"color: #339933;\">;<\/span>\r\n<span style=\"font-style: italic; color: #666666;\">\/\/\u4ec5\u5728 post \u548c movies \u4e2d\u4f7f\u7528<\/span>\r\nadd_theme_support<span style=\"color: #009900;\">(<\/span> <span style=\"color: #0000ff;\">'post-thumbnails'<\/span><span style=\"color: #339933;\">,<\/span> <span style=\"color: #990000;\">array<\/span><span style=\"color: #009900;\">(<\/span> <span style=\"color: #0000ff;\">'post'<\/span><span style=\"color: #339933;\">,<\/span> <span style=\"color: #0000ff;\">'movie'<\/span> <span style=\"color: #009900;\">)<\/span> <span style=\"color: #009900;\">)<\/span><span style=\"color: #339933;\">;<\/span> <span style=\"font-style: italic; color: #666666;\">\/\/ Posts and Movies<\/span><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p style=\"color: #000000;\">\n<h3 style=\"color: #4f9d9d;\">\u9700\u6ce8\u610f \u2014\u2013 \u4e2a\u4eba\u603b\u7ed3<\/h3>\n<p style=\"color: #000000;\">\u4e3a\u4ec0\u4e48\uff0c\u6211\u518d\u4e3b\u9898\u4e2d\u6dfb\u52a0\u4e86 add_theme_support( \u2018automatic-feed-links\u2019 ); \u5374\u6ca1\u6709\u5728\u5934\u90e8\u53d1\u73b0\u81ea\u52a8\u751f\u6210\u7684 RSS \u5730\u5740\u5462\uff1f<br \/>\n\u5f88\u7b80\u5355\uff0c\u53ea\u8981\u4f60\u5728\u5934\u90e8\u4f4d\u7f6e\u653e\u7f6e\u4e86\u5934\u90e8\u94a9\u5b50\uff0c\u81ea\u52a8\u751f\u6210\u7684rss\u5730\u5740\u5c31\u4f1a\u51fa\u73b0\u4e86\uff0c\u5982\u4e0b\uff1a<br \/>\n<code><\/code><\/p>\n<div class=\"wp_syntax\" style=\"color: #110000;\">\n<table>\n<tbody>\n<tr>\n<td class=\"code\" style=\"color: #333333;\">\n<pre class=\"php\"><span style=\"color: #339933;\">&lt;<\/span>head<span style=\"color: #339933;\">&gt;<\/span>\r\n<span style=\"color: #339933;\">...............<\/span>codes<span style=\"color: #339933;\">...........<\/span>\r\nwp_head<span style=\"color: #009900;\">(<\/span><span style=\"color: #009900;\">)<\/span><span style=\"color: #339933;\">;<\/span>\r\n<span style=\"color: #339933;\">...............<\/span>codes<span style=\"color: #339933;\">...........<\/span>\r\n<span style=\"color: #339933;\">&lt;\/<\/span>head<span style=\"color: #339933;\">&gt;<\/span><\/pre>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p style=\"color: #000000;\"><code><\/code><br \/>\n\u5177\u4f53\u6548\u679c\u561b\uff0c\u8fd8\u662f\u60a8\u81ea\u4e2a\u4eb2\u81ea\u53bb\u6f14\u7ec3\u4e00\u756a\u6bd4\u8f83\u597d\uff0c\u8fd9\u91cc\u4e5f\u5c31\u4e0d\u7ed9\u51fa\u8f93\u51fa\u4ee3\u7801\u7684\u6f14\u793a\u4e86\u3002<\/p>\n<h3 style=\"color: #4f9d9d;\">\u603b\u7ed3<\/h3>\n<p style=\"color: #000000;\"><span class='wp_keywordlink_affiliate'><a href=\"http:\/\/www.wuhaibin.com\/blog\/category\/work\/wordpress\" title=\"WordPress\" rel=\"nofollow\" target=\"_blank\">WordPress<\/a><\/span> \u8fd8\u6709\u5f88\u591a\u529f\u80fd\u7b49\u7740\u7ae5\u978b\u4eec\u53bb\u94bb\u7814\uff0c\u5f53\u7136\u6709\u65f6\u5019\u6211\u4eec\u4e3a\u4e86\u5b9e\u73b0\u4e00\u4e9b\u529f\u80fd\uff0c\u9700\u8981\u591a\u51fa\u4ee3\u7801\u914d\u5408\u624d\u80fd\u5b9e\u73b0\uff0c\u5982\u679c\u60f3\u8981\u5728\u4f60\u5f97\u4e3b\u9898\u968f\u5fc3\u6240\u6b32\u8f7b\u677e\u5b9e\u73b0\u4e00\u4e9b\u7279\u8272\u529f\u80fd\u7684\u8bdd\uff0c\u90a3\u4f60\u6700\u597d\u53bb\u53c2\u8003\u4e00\u4e0b\u5b98\u65b9\u4e3b\u9898\u8981\u6c42\u7684\u6e05\u5355\uff0c\u7136\u540e\u5927\u90e8\u5206\u5185\u5bb9\u7167\u505a\uff0c\u8fd9\u6837\u4f60\u5f97\u4e3b\u9898\u5e94\u8be5\u66f4\u80fd\u7ecf\u5f97\u8d77\u6298\u817e\uff0c\u529f\u80fd\u5b9e\u73b0\u4e5f\u5c31\u66f4\u7b80\u5355\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>WordPress \u662f\u4e00\u4e2a\u4f18\u79c0\u7684\u6587\u7ae0\u7ba1\u7406\u7cfb\u7edf\uff0c\u4e5f\u662f\u4e00\u4e2a\u4f18\u79c0\u7684\u3001\u64cd\u63a7\u6027\u826f\u597d\u7684 CMS \u6846\u67b6\uff0c\u4e0d\u5f97\u4e0d\u627f\u8ba4\u5176\u4e00\u4e9b\u529f\u80fd [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ngg_post_thumbnail":0},"categories":[30],"tags":[31],"views":4533,"_links":{"self":[{"href":"http:\/\/www.wuhaibin.com\/blog\/wp-json\/wp\/v2\/posts\/598"}],"collection":[{"href":"http:\/\/www.wuhaibin.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.wuhaibin.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.wuhaibin.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.wuhaibin.com\/blog\/wp-json\/wp\/v2\/comments?post=598"}],"version-history":[{"count":0,"href":"http:\/\/www.wuhaibin.com\/blog\/wp-json\/wp\/v2\/posts\/598\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.wuhaibin.com\/blog\/wp-json\/wp\/v2\/media?parent=598"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.wuhaibin.com\/blog\/wp-json\/wp\/v2\/categories?post=598"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.wuhaibin.com\/blog\/wp-json\/wp\/v2\/tags?post=598"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}