{"id":834,"date":"2009-01-14T21:41:26","date_gmt":"2009-01-14T13:41:26","guid":{"rendered":"https:\/\/www.wopus.org\/?p=834"},"modified":"2009-01-14T21:41:26","modified_gmt":"2009-01-14T13:41:26","slug":"extend-wp_list_authors","status":"publish","type":"post","link":"https:\/\/wopus.org\/?p=834","title":{"rendered":"WordPress\u51fd\u6570\u8be6\u89e3\u4e4bWp_list_authors"},"content":{"rendered":"<p>\u611f\u8c22<a href=\"http:\/\/www.antlite.com\/blog\" target=\"_blank\">Lia<\/a>\u7684\u6295\u9012,\u6587\u7ae0\u5df2\u7ecf\u5f88\u4e45\u4e86\uff0c\u4eca\u5929\u867d\u7136\u4eca\u5929\u53d1\u51fa\u6765\uff0c\u4f46\u8fd9\u786e\u5b9e\u662f\u4e00\u7bc7\u503c\u5f97\u770b\u7684\u6587\u7ae0\u3002<!--more--><br \/>\nwp_list_authors\u51fd\u6570\u7684\u4f5c\u7528\u662f\uff1a\u5217\u51fa\u6240\u6709\u4f5c\u8005\u548c\u6587\u7ae0\u6570\u91cf\u3002<\/p>\n<p>\u7f3a\u70b9\u662f\uff1a\u4f46\u662f\u4e0d\u80fd\u6309\u6587\u7ae0\u591a\u5c11\u6392\u5e8f\uff0c\u4ee5\u53ca\u4e0d\u80fd\u591f\u9650\u5236\u8f93\u51fa\u4f5c\u8005\u7684\u4e2a\u6570\u3002<\/p>\n<p>\u6269\u5c55\u76ee\u7684\uff1a<\/p>\n<p>1. \u8f93\u51fa\u6587\u7ae0\u6700\u591a\u7684\u4f5c\u8005\uff0c\u5e76\u6309\u6587\u7ae0\u6570\u91cf\u6392\u5e8f\uff1b<br \/>\n2. \u81ea\u5b9a\u4e49\u8f93\u51fa\u4f5c\u8005\u7684\u4e2a\u6570\u3002<\/p>\n<p><strong>\u4fee\u6539\u7684\u5185\u5bb9\uff1a<\/strong><br \/>\n1. \u4e3a wp_list_authors \u51fd\u6570\u589e\u52a0\u4e24\u4e2a\u63a7\u5236\u53d8\u91cf\uff1alimited \u548c order<br \/>\n<coolcode><br \/>\n$defaults = array(<br \/>\n  &#8216;optioncount&#8217; => false, &#8216;exclude_admin&#8217; => true,<br \/>\n  &#8216;show_fullname&#8217; => false, &#8216;hide_empty&#8217; => true,<br \/>\n  &#8216;feed&#8217; => &#8221;, &#8216;feed_image&#8217; => &#8221;, &#8216;feed_type&#8217; => &#8221;, &#8216;echo&#8217; => true,<br \/>\n  &#8216;limited&#8217; => 5, &#8216;order&#8217; => &#8216;DESC&#8217;<br \/>\n);<br \/>\n<\/coolcode><\/p>\n<p>2. \u91cd\u65b0\u6784\u5efa\u67e5\u8be2\u8bed\u53e5<br \/>\n<coolcode><br \/>\n\/** @todo Move select to get_authors(). *\/<br \/>\n$authors = $wpdb->get_results(&#8220;SELECT DISTINCT u.ID, u.user_nicename, COUNT( p.ID ) AS count from $wpdb->users AS u, $wpdb->posts AS p &#8221; . ($exclude_admin ? &#8220;WHERE u.user_login <> &#8216;admin&#8217; AND &#8221; : &#8216;WHERE &#8216;) . &#8220;p.post_author = u.ID AND p.post_type = &#8216;post&#8217; AND ( p.post_status = &#8216;publish&#8217; OR p.post_status = &#8216;private&#8217;) GROUP BY p.post_author ORDER BY count &#8221; . $order . &#8220;, display_name ASC&#8221; . ( ($limited >= 0) ? ( &#8216; LIMIT &#8216; . $limited ) : &#8221;) );<br \/>\n<\/coolcode><\/p>\n<p>wp_list_authors\u76f8\u5173\u53c2\u6570\uff1a<br \/>\n1. wp_list_authors \u7684\u9ed8\u8ba4\u53c2\u6570\uff1a<\/p>\n<p>optioncount<br \/>\n    (boolean) \u663e\u793a\u4f5c\u8005\u6587\u7ae0\u6570\u3002<\/p>\n<p>        * 1 (true)<br \/>\n        * 0 (false &#8211; \u9ed8\u8ba4)<\/p>\n<p>exclude_admin<br \/>\n    (boolean) \u5254\u9664admin\u3002<\/p>\n<p>        * 1 (true &#8211; \u9ed8\u8ba4)<br \/>\n        * 0 (false)<\/p>\n<p>show_fullname<br \/>\n    (boolean) \u663e\u793a\u4f5c\u8005\u5168\u540d\u3002 \u9ed8\u8ba4\u663e\u793a\u4f5c\u8005\u6635\u79f0\u3002<\/p>\n<p>        * 1 (true)<br \/>\n        * 0 (false &#8211; \u9ed8\u8ba4)<\/p>\n<p>hide_empty<br \/>\n    (boolean) \u9690\u85cf\u5c1a\u672a\u53d1\u8868\u6587\u7ae0\u7684\u4f5c\u8005\u3002<\/p>\n<p>        * 1 (true &#8211; \u9ed8\u8ba4)<br \/>\n        * 0 (false)<\/p>\n<p>feed<br \/>\n    (string) \u94fe\u63a5\u5230\u4f5c\u8005 RSS feed \u7684\u663e\u793a\u6587\u5b57\u3002\u9ed8\u8ba4\u4e0d\u663e\u793a\u3002<br \/>\nfeed_image<br \/>\n    (string) \u94fe\u63a5\u5230\u4f5c\u8005 RSS feed \u7684\u56fe\u7247\u7684\u76ee\u5f55\u548c\u6587\u4ef6\u540d\u3002\u5982\u679c\u5b9a\u4e49\u4e86 feed_image\uff0c\u5c06\u4f1a\u8986\u76d6 feed \u5b9a\u4e49\u7684\u6587\u5b57\u3002 <\/p>\n<p>2. \u6269\u5c55\u53c2\u6570\uff1a<\/p>\n<p>limit<br \/>\n    (int) \u8f93\u51fa\u4f5c\u8005\u6570\u76ee\u3002<\/p>\n<p>        * 5 ( \u9ed8\u8ba4)<br \/>\n        * 0 (\u663e\u793a\u5168\u90e8\u4f5c\u8005)<\/p>\n<p>order<br \/>\n    (string) \u6392\u5e8f\u65b9\u5f0f\u3002<\/p>\n<p>        * DESC (\u964d\u5e8f &#8211; \u9ed8\u8ba4)<br \/>\n        * ASC (\u5347\u5e8f &#8211; \u663e\u793a\u6700\u4e0d\u6d3b\u8dc3\u7684\u4f5c\u8005)<\/p>\n<p>\u7528\u6cd5\uff1a<\/p>\n<p>\u60a8\u53ef\u4ee5\u5c06 wp_list_authors \u590d\u5236\u5230\u4e3b\u9898\u6587\u4ef6\u7684functions.php \u4e2d\u8fdb\u884c\u4fee\u6539\uff0c\u5e76\u66f4\u6362\u51fd\u6570\u540d\u79f0\uff0c\u6bd4\u5982\uff1amost_active_authors\uff0c\u5728\u9700\u8981\u663e\u793a\u7684\u4f4d\u7f6e\u8c03\u7528\u8fd9\u4e2a\u51fd\u6570\u5c31\u53ef\u4ee5\u4e86\u3002\u5982\uff1a<\/p>\n<p><strong>\u663e\u793a\u6587\u7ae0\u6700\u591a\u7684\u524d10\u540d\u4f5c\u8005\u3001\u6587\u7ae0\u6570\u91cf\uff1a<\/strong><br \/>\n<coolcode><\/p>\n<ul>\n< ?php most_active_authors('optioncount=1&#038;limit=10'); ?>\n<\/ul>\n<p><\/coolcode><\/p>\n<p><strong>\u663e\u793a\u524d5\u540d\u6700\u4e0d\u6d3b\u8dc3\u7684\u4f5c\u8005\uff0c\u4e0d\u663e\u793a\u6587\u7ae0\u6570\u91cf\uff1a<\/strong><br \/>\n<coolcode><\/p>\n<ul>\n< ?php most_active_authors('order=ASC'); ?>\n<\/ul>\n<p><\/coolcode><\/p>\n<p><strong>\u8bf4\u660e\uff1a<\/strong>wp_list_authors \u51fd\u6570\u4f4d\u4e8e wp-includes \u76ee\u5f55\u4e0b\u7684 author-template.php \u6587\u4ef6\u4e2d\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u611f\u8c22Lia\u7684\u6295\u9012,\u6587\u7ae0\u5df2\u7ecf\u5f88\u4e45\u4e86\uff0c\u4eca\u5929\u867d\u7136\u4eca\u5929\u53d1\u51fa\u6765\uff0c\u4f46\u8fd9\u786e\u5b9e\u662f\u4e00\u7bc7\u503c\u5f97\u770b\u7684\u6587\u7ae0\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[25],"tags":[313,680],"class_list":["post-834","post","type-post","status-publish","format-standard","hentry","category-tech","tag-wordpress","tag-wp_list_authors"],"_links":{"self":[{"href":"https:\/\/wopus.org\/index.php?rest_route=\/wp\/v2\/posts\/834","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=834"}],"version-history":[{"count":0,"href":"https:\/\/wopus.org\/index.php?rest_route=\/wp\/v2\/posts\/834\/revisions"}],"wp:attachment":[{"href":"https:\/\/wopus.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=834"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wopus.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=834"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wopus.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=834"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}