{"id":697,"date":"2008-11-20T15:52:30","date_gmt":"2008-11-20T07:52:30","guid":{"rendered":"https:\/\/www.wopus.org\/?p=697"},"modified":"2008-11-20T15:52:30","modified_gmt":"2008-11-20T07:52:30","slug":"extend-wp_list_authors-and-get_more_active_authors","status":"publish","type":"post","link":"https:\/\/wopus.org\/?p=697","title":{"rendered":"\u589e\u5f3a wp_list_authors \u663e\u793a\u6587\u7ae0\u6700\u591a\u7684\u4f5c\u8005"},"content":{"rendered":"<p>\u9996\u5148\u611f\u8c22 <a href=\"http:\/\/www.antlite.com\/blog\/2008\/11\/extend-wp_list_authors-and-get_more_active_authors\/\" target=\"_blank\">Lia<\/a> \u7684\u6295\u7a3f<!--more--><br \/>\nWordpress \u7684 wp_list_authors \u51fd\u6570\u80fd\u591f\u5217\u51fa\u6240\u6709\u4f5c\u8005\u548c\u6587\u7ae0\u6570\u91cf\uff0c\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\u4e8e\u662f <a href=\"http:\/\/www.antlite.com\/\" target=\"_blank\">Lia<\/a> \u81ea\u5df1\u52a8\u624b\uff0c\u589e\u5f3a\u4e86 wp_list_authors \u51fd\u6570\u529f\u80fd\u3002<br \/>\n<strong>\u9700\u8981\u6269\u5c55\u7684\u529f\u80fd\uff1a<\/strong><br \/>\n1. \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<br \/>\n<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><br \/>\n2. \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><br \/>\n<strong>\u53c2\u6570\uff1a<\/strong><br \/>\n1. wp_list_authors \u7684\u9ed8\u8ba4\u53c2\u6570\uff1a<br \/>\n<strong>optioncount<\/strong><br \/>\n    (boolean) \u663e\u793a\u4f5c\u8005\u6587\u7ae0\u6570\u3002<br \/>\n1 (true)<br \/>\n0 (false &#8211; \u9ed8\u8ba4)<\/p>\n<p><strong>exclude_admin<\/strong><br \/>\n    (boolean) \u5254\u9664admin\u3002<br \/>\n1 (true &#8211; \u9ed8\u8ba4)<br \/>\n0 (false)<\/p>\n<p><strong> show_fullname<\/strong><br \/>\n    (boolean) \u663e\u793a\u4f5c\u8005\u5168\u540d\u3002 \u9ed8\u8ba4\u663e\u793a\u4f5c\u8005\u6635\u79f0\u3002<br \/>\n1 (true)<br \/>\n0 (false &#8211; \u9ed8\u8ba4)<\/p>\n<p><strong>hide_empty<\/strong><br \/>\n    (boolean) \u9690\u85cf\u5c1a\u672a\u53d1\u8868\u6587\u7ae0\u7684\u4f5c\u8005\u3002<br \/>\n1 (true &#8211; \u9ed8\u8ba4)<br \/>\n0 (false)<\/p>\n<p><strong>feed<\/strong><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<br \/>\n2. \u6269\u5c55\u53c2\u6570\uff1a<\/p>\n<p><strong>limited<\/strong><br \/>\n    (int) \u8f93\u51fa\u4f5c\u8005\u6570\u76ee\u3002<br \/>\n5 ( \u9ed8\u8ba4)<br \/>\n0 (\u663e\u793a\u5168\u90e8\u4f5c\u8005)<\/p>\n<p><strong>order<\/strong><br \/>\n    (string) \u6392\u5e8f\u65b9\u5f0f\u3002<br \/>\nDESC (\u964d\u5e8f &#8211; \u9ed8\u8ba4)<br \/>\nASC (\u5347\u5e8f &#8211; \u663e\u793a\u6700\u4e0d\u6d3b\u8dc3\u7684\u4f5c\u8005)<\/p>\n<p><strong>\u7528\u6cd5\uff1a<\/strong><\/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;limited=10'); ?>\n<\/ul>\n<p><\/coolcode><br \/>\n<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><br \/>\nwp_list_authors \u51fd\u6570\u4f4d\u4e8e wp-includes \u76ee\u5f55\u4e0b\u7684 author-template.php \u6587\u4ef6\u4e2d\u3002<br \/>\n<strong>\u8ba1\u5212:\u52a0\u5165 gravatar \u5934\u50cf\uff0c\u5236\u4f5c\u4e00\u4e2a\u63d2\u4ef6\u3002<\/strong><br \/>\n<strong>\u8f90\u5c04\u9c7c\u8865\u5145\uff1a\u4e2a\u4eba\u611f\u89c9\u6ca1\u5fc5\u8981\u505a\u6210\u63d2\u4ef6\u4e86\uff0c\u53ea\u9700\u8981\u52a0\u4e0a\u5982\u4e0b\u8bed\u53e5\u5373\u53ef<\/strong><br \/>\n<coolcode><br \/>\n< ?php\n\t$author_email = get_the_author_email();\n\techo get_avatar($author_email, '50', 'wavatar');\n?><br \/>\n<\/coolcode><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u9996\u5148\u611f\u8c22 Lia \u7684\u6295\u7a3f<\/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":[],"class_list":["post-697","post","type-post","status-publish","format-standard","hentry","category-tech"],"_links":{"self":[{"href":"https:\/\/wopus.org\/index.php?rest_route=\/wp\/v2\/posts\/697","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=697"}],"version-history":[{"count":0,"href":"https:\/\/wopus.org\/index.php?rest_route=\/wp\/v2\/posts\/697\/revisions"}],"wp:attachment":[{"href":"https:\/\/wopus.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=697"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wopus.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=697"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wopus.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=697"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}