{"id":416,"date":"2008-09-14T15:59:13","date_gmt":"2008-09-14T07:59:13","guid":{"rendered":"https:\/\/www.wopus.org\/?p=416"},"modified":"2008-09-14T15:59:13","modified_gmt":"2008-09-14T07:59:13","slug":"how-to-use-wp_list_categories","status":"publish","type":"post","link":"https:\/\/wopus.org\/?p=416","title":{"rendered":"wp_list_categories\u51fd\u6570\u7528\u6cd5\u8be6\u89e3"},"content":{"rendered":"<p>\u672c\u4ee5\u4e3a\u5199\u5b8c<a href=\"https:\/\/www.wopus.org\/wordpress-freshman-course.html\" target=\"_blank\">\u65b0\u624b\u6559\u7a0b<\/a>\u4e4b\u540e\uff0c\u53ef\u4ee5\u4e0d\u5199\u65b0\u624b\u5e94\u7528\u65b9\u9762\u7684\u6587\u7ae0\u4e86\u7684\uff0c\u53ef\u4eca\u5929\u53c8\u6709\u670b\u53cb\u5728\u7fa4\u91cc\u95ee\u5982\u4f55\u663e\u793a\u6bcf\u4e2a\u5206\u7c7b\u4e0b\u6587\u7ae0\u6570\u91cf\u8fd9\u4e2a\u57fa\u7840\u6027\u95ee\u9898\uff0c\u770b\u6765Wordpress\u4e2d\u6587\u5316\u8fd8\u6709\u5f88\u957f\u7684\u4e00\u6bb5\u8def\u8981\u8d70\uff0c\u6211\u4eec\u4efb\u91cd\u800c\u9053\u8fdc\u554a\uff01\u597d\uff0c\u89e3\u51b3\u4f60\u7684\u95ee\u9898\u5148\uff1a<br \/>\n\u6b63\u5982\u6807\u9898\u6240\u8bf4\uff0cWordpress\u662f\u7528wp_list_categories\u8fd9\u4e2a\u51fd\u6570\u6765\u663e\u793a\u5206\u7c7b\u7684\uff0c\u5176\u7528\u6cd5\u662f\uff1a<br \/>\n<coolcode lang=\"php\" linenum=\"off\">< ?php wp_list_categories('arguments'); ?><\/coolcode><br \/>\n<strong>arguments<\/strong>\u5373\u53c2\u6570\uff0c\u9ed8\u8ba4\u53c2\u6570\u8bbe\u7f6e\u4e3a\uff1a<br \/>\n<!--more--><br \/>\n<coolcode lang=\"php\"><br \/>\n$defaults = array(<br \/>\n&#8216;show_option_all&#8217; => &#8221;, \u4e0d\u5217\u51fa\u5206\u7c7b\u94fe\u63a5<br \/>\n&#8216;orderby&#8217; => &#8216;name&#8217;, \u6309\u7167\u5206\u7c7b\u540d\u6392\u5e8f<br \/>\n&#8216;order&#8217; => &#8216;ASC&#8217;, \u5347\u5e8f\u6392\u5217<br \/>\n&#8216;show_last_update&#8217; => 0, \u4e0d\u663e\u793a\u5206\u7c7b\u4e2d\u65e5\u5fd7\u7684\u6700\u65b0\u65f6\u95f4\u6233<br \/>\n&#8216;style&#8217; => &#8216;list&#8217;,\u5217\u8868\u663e\u793a\u5206\u7c7b<br \/>\n&#8216;show_count&#8217; => 0, \u4e0d\u663e\u793a\u5206\u7c7b\u65e5\u5fd7\u6570\u91cf<br \/>\n&#8216;hide_empty&#8217; => 1, \u4e0d\u663e\u793a\u6ca1\u6709\u65e5\u5fd7\u7684\u5206\u7c7b<br \/>\n&#8216;use_desc_for_title&#8217; => 1, \u663e\u793a\u5206\u7c7b\u63cf\u8ff0<br \/>\n&#8216;child_of&#8217; => 0, \u4e0d\u9650\u5236\u5b50\u5206\u7c7b<br \/>\n&#8216;feed&#8217; => &#8221;, \u4e0d\u663e\u793afeed<br \/>\n&#8216;feed_image&#8217; => &#8221;, \u4e0d\u663e\u793afeed\u56fe\u7247<br \/>\n&#8216;exclude&#8217; => &#8221;, \u4e0d\u663e\u793a\u8be5\u5206\u7c7b<br \/>\n&#8216;hierarchical&#8217; => true, \u5206\u5c42\u6b21\u663e\u793a\u7236\/\u5b50\u5206\u7c7b<br \/>\n&#8216;title_li&#8217; => __(&#8216;Categories&#8217;), \u7528\u201cCategories\u201d\u4e3a\u5f53\u524d\u5206\u7c7b\u5217\u8868\u7684\u6807\u9898<br \/>\n&#8216;echo&#8217; => 1, \u663e\u793a(echos) \u5206\u7c7b<br \/>\n&#8216;depth&#8217; => 0 \u4e0d\u9650\u5236\u5217\u8868\u6df1\u5ea6<br \/>\n);<br \/>\n<\/coolcode><br \/>\n<strong>\u7528\u6cd5\u4e3e\u4f8b\uff1a<\/strong><\/p>\n<ol>\n<li>\u6309\u7167\u5206\u7c7b\u540d\u6392\u5e8f\uff0c\u5e76\u53ea\u663e\u793a ID \u4e3a1\u30012\u30013\u548c4\u7684\u5206\u7c7b\uff1a<\/li>\n<p><coolcode lang=\"php\"><\/p>\n<ul>\n< ?php\nwp_list_categories('orderby=name&#038;include=1,2,3,4'); ?>\n<\/ul>\n<p><\/coolcode><\/p>\n<li>\u6309\u7167\u5206\u7c7b\u540d\u6392\u5e8f\uff0c\u5e76\u663e\u793a\u6bcf\u4e2a\u5206\u7c7b\u7684\u65e5\u5fd7\u6570\uff0c\u4f46\u4e0d\u663e\u793a ID \u4e3a10\u7684\u5206\u7c7b<\/li>\n<p><coolcode lang=\"php\"><\/p>\n<ul>\n< ?php\nwp_list_categories('orderby=name&#038;show_count=1&#038;exclude=10'); ?>\n<\/ul>\n<p><\/coolcode><\/p>\n<li>\u663e\u793a\u6216\u9690\u85cf\u5217\u8868\u6807\u9898<\/li>\n<p>title_li \u8fd9\u4e2a\u53c2\u6570\u7528\u4e8e\u663e\u793a\u6216\u8005\u9690\u85cf\u5206\u7c7b\u5217\u8868\u7684\u6807\u9898\uff0c\u5b83\u7684\u9ed8\u8ba4\u503c\u4e3a'(__(&#8216;Categories&#8217;)&#8217;\uff0c\u5373\u663e\u793a\u5206\u7c7b\u5217\u8868\u7684\u6807\u9898\uff0c\u5982\u679c\u4e0d\u8bbe\u7f6e\u6216\u8bbe\u7f6e\u4e3a\u7a7a\uff0c\u5b83\u5c06\u4ec0\u4e48\u4e5f\u4e0d\u663e\u793a\u3002\u4e0b\u9762\u7684\u4f8b\u5b50\u5c06\u4e0d\u663e\u793aid\u4e3a4\u548c7\u7684\u5206\u7c7b\uff0c\u5e76\u4e0d\u663e\u793alist_categories\u5217\u8868\u7684\u6807\u9898\uff1a<br \/>\n<coolcode lang=\"php\"><\/p>\n<ul>\n< ?php\nwp_list_categories('exclude=4,7&#038;title_li='); ?>\n<\/ul>\n<p><\/coolcode><br \/>\n\u63a5\u4e0b\u6765\u7684\u4f8b\u5b50\u662f\u4ec5\u4ec5\u53ea\u663e\u793a ID\u4e3a5\u30019\u548c23\u7684\u5206\u7c7b\uff0c\u5e76\u4e14\u5217\u8868\u6807\u9898\u663e\u793a\u4e3a\u201cPoetry\u201d\u8868\uff1a<br \/>\n<coolcode lang=\"php\"><\/p>\n<ul>\n< ?php\nwp_list_categories('include=5,9,23&#038;title_li=\n\n<h2>&#8216; . __(&#8216;Poetry&#8217;) . &#8221; ); ?>\n<\/ul>\n<p><\/coolcode><\/p>\n<li>\u4ec5\u663e\u793a\u67d0\u4e2a\u5206\u7c7b\u4e0b\u7684\u5b50\u5206\u7c7b<\/li>\n<p>\u4e0b\u9762\u7684\u793a\u4f8b\u4ee3\u7801\u751f\u6210\u4e86 ID \u4e3a8\u7684\u7236\u5206\u7c7b\u4e0b\u7684\u5b50\u5206\u7c7b\u6839\u636e\u5176 ID \u8fdb\u884c\u6392\u5e8f\u7684\u94fe\u63a5\u5217\u8868\uff0c\u5b83\u4f1a\u663e\u793a\u6bcf\u4e2a\u5206\u7c7b\u4e0b\u7684\u6587\u7ae0\u6570\uff0c\u5e76\u4e14\u9690\u85cf\u94fe\u63a5\u7684 title \u6807\u7b7e\u4e2d\u7684\u5206\u7c7b\u63cf\u8ff0\uff0c\u6ce8\u610f\uff1a\u5982\u679c\u7236\u5206\u7c7b\u4e0b\u6ca1\u6709\u4efb\u4f55\u6587\u7ae0\uff0c\u90a3\u4e48\u7236\u5206\u7c7b\u5c06\u4e0d\u4f1a\u663e\u793a\uff08\u8bfb\u8d77\u6765\u8c8c\u4f3c\u5f88\u96be\u7406\u89e3\uff0c\u4e0d\u8fc7\u7167\u7740\u505a\u5c31\u7406\u89e3\u4e86\uff09<br \/>\n<coolcode lang=\"php\"><\/p>\n<ul>\n< ?php wp_list_categories('orderby=id&#038;show_count=1\n&#038;use_desc_for_title=0&#038;child_of=8'); ?>\n<\/ul>\n<p><\/coolcode><\/p>\n<li>\u663e\u793a\u5e26\u6709 RSS Feed \u94fe\u63a5\u7684\u5206\u7c7b\u5217\u8868<\/li>\n<p>\u9762\u4ee3\u7801\u6839\u636e\u5206\u7c7b\u540d\u5bf9\u5206\u7c7b\u5217\u8868\u6392\u5e8f\uff0c\u5e76\u663e\u793a\u6bcf\u4e2a\u5206\u7c7b\u4e0b\u7684\u6587\u7ae0\u6570\u548c RSS \u7684 Feed \u94fe\u63a5\uff1a<br \/>\n<coolcode lang=\"php\"><\/p>\n<ul>\n< ?php\nwp_list_categories('orderby=name&#038;show_count=1&#038;feed=RSS'); ?>\n<\/ul>\n<p><\/coolcode><br \/>\n\u8fd8\u53ef\u4ee5\u4f7f\u7528 RSS \u56fe\u6807\u4ee3\u66ff RSS \u94fe\u63a5<br \/>\n<coolcode lang=\"php\"><\/p>\n<ul>\n< ?php\nwp_list_categories('orderby=name&#038;show_count=1\n&#038;feed_image=\/images\/rss.gif'); ?>\n<\/ul>\n<p><\/coolcode>\n<\/ol>\n<p>\u597d\u4e86\uff0c\u95ee\u9898\u57fa\u672c\u89e3\u51b3\u4e86\uff0c\u6709\u4ec0\u4e48\u4e0d\u61c2\u8bf7\u63d0\u51fa\u6765\uff01<br \/>\n\u7ffb\u8bd1\u8fd9\u7bc7\u6587\u7ae0\u597d\u7d2f\u554a\uff0c\u8001\u81ed\u8001\u957f\u7684\uff0c\u5f88\u591a\u4eba\u8fd8\u53eb\u56a3\u770b\u4e0d\u61c2\uff0c\u4e0d\u80fd\u518d\u7b80\u5355\u5566\uff01\u8001\u89c4\u77e9\uff0c\u8d34\u4e0b<a href=\"http:\/\/codex.wordpress.org\/Template_Tags\/wp_list_categories\" target=\"_blank\">\u539f\u6587\u5730\u5740<\/a>\u3002<br \/>\n\u8c01\u5bb6\u6709\u591a\u7684\u6708\u997c\uff0c\u63b7\u8fc7\u6765\u7292\u52b3\u7292\u52b3\u5148\uff1f\uff01\u563f\u563f\uff0c\u7b11\u8bdd\u4e86\uff0c\u4eca\u5929\u662f\u4e2d\u79cb\u8282\uff0c\u672c\u9c7c\u4ee3\u8868<a href=\"https:\/\/www.wopus.org\/contact\" target=\"_blank\">Wopus\u56e2\u961f<\/a>\u5168\u4f53\u6210\u5458\u5728\u8fd9\u91cc\u771f\u8bda\u7684\u795d\u798f\u5927\u5bb6<strong>\u201c\u5343\u597d\u4e07\u597d\u4e8b\u4e8b\u597d\u3001\u6708\u5706\u60c5\u5706\u4eba\u56e2\u5706\u201d<\/strong>\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u672c\u4ee5\u4e3a\u5199\u5b8c\u65b0\u624b\u6559\u7a0b\u4e4b\u540e\uff0c\u53ef\u4ee5\u4e0d\u5199\u65b0\u624b\u5e94\u7528\u65b9\u9762\u7684\u6587\u7ae0\u4e86\u7684\uff0c\u53ef\u4eca\u5929\u53c8\u6709\u670b\u53cb\u5728\u7fa4\u91cc\u95ee\u5982\u4f55\u663e\u793a\u6bcf\u4e2a\u5206\u7c7b\u4e0b\u6587\u7ae0\u6570\u91cf\u8fd9\u4e2a\u57fa\u7840\u6027\u95ee\u9898\uff0c\u770b\u6765Wordpress\u4e2d\u6587\u5316\u8fd8\u6709\u5f88\u957f\u7684\u4e00\u6bb5\u8def\u8981\u8d70\uff0c\u6211\u4eec\u4efb\u91cd\u800c\u9053\u8fdc\u554a\uff01\u597d\uff0c\u89e3\u51b3\u4f60\u7684\u95ee\u9898\u5148\uff1a \u6b63\u5982\u6807\u9898\u6240\u8bf4\uff0cWordpress\u662f\u7528wp_list_categories\u8fd9\u4e2a\u51fd\u6570\u6765\u663e\u793a\u5206\u7c7b\u7684\uff0c\u5176\u7528\u6cd5\u662f\uff1a < ?php wp_list_categories('arguments'); ?> arguments\u5373\u53c2\u6570\uff0c\u9ed8\u8ba4\u53c2\u6570\u8bbe\u7f6e\u4e3a\uff1a<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19],"tags":[106,313,722],"class_list":["post-416","post","type-post","status-publish","format-standard","hentry","category-basic-use","tag-categories","tag-wordpress","tag-code"],"_links":{"self":[{"href":"https:\/\/wopus.org\/index.php?rest_route=\/wp\/v2\/posts\/416","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wopus.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wopus.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wopus.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wopus.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=416"}],"version-history":[{"count":0,"href":"https:\/\/wopus.org\/index.php?rest_route=\/wp\/v2\/posts\/416\/revisions"}],"wp:attachment":[{"href":"https:\/\/wopus.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=416"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wopus.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=416"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wopus.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=416"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}