{"id":30346,"date":"2024-11-25T14:51:56","date_gmt":"2024-11-25T06:51:56","guid":{"rendered":"https:\/\/fwq.ai\/blog\/30346\/"},"modified":"2024-11-25T14:51:56","modified_gmt":"2024-11-25T06:51:56","slug":"%e5%a6%82%e4%bd%95%e6%8c%89%e8%af%84%e8%ae%ba%e6%95%b0%e9%87%8f%e6%98%be%e7%a4%ba%e5%89%8d100%e5%90%8d%e8%af%84%e8%ae%ba%e8%80%85","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/30346\/","title":{"rendered":"\u5982\u4f55\u6309\u8bc4\u8bba\u6570\u91cf\u663e\u793a\u524d100\u540d\u8bc4\u8bba\u8005"},"content":{"rendered":"<p>\u4e0b\u9762\u7531\/&#8221; target=&#8221;_blank&#8221;&gt;<strong>wordpress\u5efa\u7ad9<\/strong><strong>\u6559\u7a0b<\/strong>\u680f\u76ee\u7ed9\u5927\u5bb6\u4ecb\u7ecd\u6309\u8bc4\u8bba\u6570\u91cf\u663e\u793a\u524d100\u540d\u8bc4\u8bba\u8005\u7684\u65b9\u6cd5\uff0c\u5e0c\u671b\u5bf9\u9700\u8981\u7684\u670b\u53cb\u6709\u6240\u5e2e\u52a9\uff01<\/p>\n<p style=\"text-align: center\"><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/000\/000\/020\/5df47ed287abc247.jpg\" class=\"aligncenter\" title=\"\u5982\u4f55\u6309\u8bc4\u8bba\u6570\u91cf\u663e\u793a\u524d100\u540d\u8bc4\u8bba\u8005\u63d2\u56fe\" alt=\"\u5982\u4f55\u6309\u8bc4\u8bba\u6570\u91cf\u663e\u793a\u524d100\u540d\u8bc4\u8bba\u8005\u63d2\u56fe\" \/><\/p>\n<p>\u5982\u60f3\u770b\u770b\u81ea\u5df1\u535a\u5ba2\u4e0a\u54ea\u4f4d\u535a\u53cb\u7684\u7559\u8a00\u8bc4\u8bba\u6700\u591a\u53ca\u6700\u540e\u7684\u8bc4\u8bba\u65f6\u95f4\uff0c\u4e0b\u9762\u4e00\u6bb5\u4ee3\u7801\u4f1a\u5e2e\u4f60\u5b9e\u73b0\u8fd9\u4e2a\u529f\u80fd\u3002<\/p>\n<p>\u53ef\u4ee5\u5c06\u4e0b\u9762\u4ee3\u7801\u6dfb\u52a0\u5230\u5f53\u524d\u4e3b\u9898functions.php\u4e2d\uff1a<\/p>\n<pre>function&nbsp;top_comment_authors($amount&nbsp;=&nbsp;100)&nbsp;{\n&nbsp;&nbsp;&nbsp;&nbsp;global&nbsp;$wpdb;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$prepared_statement&nbsp;=&nbsp;$wpdb-&amp;gt;prepare(\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'SELECT\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;COUNT(comment_author)&nbsp;AS&nbsp;comments_count,&nbsp;comment_author,&nbsp;comment_author_url,&nbsp;MAX(&nbsp;comment_date&nbsp;)&nbsp;as&nbsp;last_commented_date\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;FROM&nbsp;'.$wpdb-&amp;gt;comments.'\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;WHERE&nbsp;comment_author&nbsp;!=&nbsp;\"\"&nbsp;AND&nbsp;comment_type&nbsp;=&nbsp;\"\"&nbsp;AND&nbsp;comment_approved&nbsp;=&nbsp;1\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;GROUP&nbsp;BY&nbsp;comment_author\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ORDER&nbsp;BY&nbsp;comments_count&nbsp;DESC,&nbsp;comment_author&nbsp;ASC\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;LIMIT&nbsp;%d',\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$amount);\n&nbsp;&nbsp;&nbsp;&nbsp;$results&nbsp;=&nbsp;$wpdb-&amp;gt;get_results($prepared_statement);\n&nbsp;&nbsp;&nbsp;&nbsp;$output&nbsp;=&nbsp;'<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<ul>\n  &#8216;; &nbsp;&nbsp;&nbsp;&nbsp;foreach($results&nbsp;as&nbsp;$result)&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$output&nbsp;.=&nbsp;&#8216; <\/p>\n<li> <strong>&nbsp;<\/strong>&nbsp;\u5171&#8217;.$result-&gt;comments_count.&#8217;&nbsp;\u6761\u8bc4\u8bba\uff0c\u6700\u540e\u8bc4\u8bba&nbsp;&#8216;.human_time_diff(strtotime($result-&gt;last_commented_date)).&#8217;\u524d<\/li>\n<p>&#8216;; &nbsp;&nbsp;&nbsp;&nbsp;} &nbsp;&nbsp;&nbsp;&nbsp;$output&nbsp;.=&nbsp;&#8216;\n<\/ul>\n<p>&#8216;; &nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;$output; } <\/p>\n<p>\u8c03\u7528\u4ee3\u7801\uff1a<\/p>\n<pre>&lt;?php  top_comment_authors(100); ?&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5c06\u4ee3\u7801\u6dfb\u52a0\u5230\u4e3b\u9898\u6a21\u677f\u9002\u5f53\u4f4d\u7f6e\u5373\u53ef\uff0c\u5176\u4e2d\u7684\u6570\u5b57100\u53ef\u4ee5\u63a7\u5236\u663e\u793a\u6570\u91cf\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u6309\u8bc4\u8bba\u6570\u91cf\u663e\u793a\u524d100\u540d\u8bc4\u8bba\u8005\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e0b\u9762\u7531\/&#8221; target=&#8221;_blank&#8221;&gt;wordpress\u5efa\u7ad9\u6559\u7a0b\u680f\u76ee\u7ed9\u5927\u5bb6\u4ecb\u7ecd\u6309\u8bc4\u8bba\u6570\u91cf\u663e\u793a\u524d100\u540d\u8bc4\u8bba\u8005\u7684\u65b9\u6cd5\uff0c\u5e0c\u671b\u5bf9\u9700\u8981\u7684\u670b\u53cb\u6709\u6240\u5e2e\u52a9\uff01 \u5982\u60f3\u770b\u770b\u81ea\u5df1\u535a\u5ba2\u4e0a\u54ea\u4f4d\u535a\u53cb\u7684\u7559\u8a00\u8bc4\u8bba\u6700\u591a\u53ca\u6700\u540e\u7684\u8bc4\u8bba\u65f6\u95f4\uff0c\u4e0b\u9762\u4e00\u6bb5\u4ee3\u7801\u4f1a\u5e2e\u4f60\u5b9e\u73b0\u8fd9\u4e2a\u529f\u80fd\u3002 \u53ef\u4ee5\u5c06\u4e0b\u9762\u4ee3\u7801\u6dfb\u52a0\u5230\u5f53\u524d\u4e3b\u9898functions.php\u4e2d\uff1a function&nbsp;top_comment_authors($amount&nbsp;=&nbsp;100)&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;global&nbsp;$wpdb; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$prepared_statement&nbsp;=&nbsp;$wpdb-&amp;gt;prepare( &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#8216;SELECT &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;COUNT(comment_author)&nbsp;AS&nbsp;comments_count,&nbsp;comment_author,&nbsp;comment_author_url,&nbsp;MAX(&nbsp;comment_date&nbsp;)&nbsp;as&nbsp;last_commented_date &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;FROM&nbsp;&#8216;.$wpdb-&amp;gt;comments.&#8217; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;WHERE&nbsp;comment_author&nbsp;!=&nbsp;&#8220;&#8221;&nbsp;AND&nbsp;comment_type&nbsp;=&nbsp;&#8220;&#8221;&nbsp;AND&nbsp;comment_approved&nbsp;=&nbsp;1 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;GROUP&nbsp;BY&nbsp;comment_author &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ORDER&nbsp;BY&nbsp;comments_count&nbsp;DESC,&nbsp;comment_author&nbsp;ASC &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;LIMIT&nbsp;%d&#8217;, &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$amount); &nbsp;&nbsp;&nbsp;&nbsp;$results&nbsp;=&nbsp;$wpdb-&amp;gt;get_results($prepared_statement); &nbsp;&nbsp;&nbsp;&nbsp;$output&nbsp;=&nbsp;&#8216; \u767b\u5f55\u540e\u590d\u5236 &#8216;; &nbsp;&nbsp;&nbsp;&nbsp;foreach($results&nbsp;as&nbsp;$result)&nbsp;{ &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$output&nbsp;.=&nbsp;&#8216; &nbsp;&nbsp;\u5171&#8217;.$result-&gt;comments_count.&#8217;&nbsp;\u6761\u8bc4\u8bba\uff0c\u6700\u540e\u8bc4\u8bba&nbsp;&#8216;.human_time_diff(strtotime($result-&gt;last_commented_date)).&#8217;\u524d &#8216;; &nbsp;&nbsp;&nbsp;&nbsp;} &nbsp;&nbsp;&nbsp;&nbsp;$output&nbsp;.=&nbsp;&#8216; &#8216;; &nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;$output; } \u8c03\u7528\u4ee3\u7801\uff1a &lt;?php top_comment_authors(100); ?&gt; \u767b\u5f55\u540e\u590d\u5236 \u5c06\u4ee3\u7801\u6dfb\u52a0\u5230\u4e3b\u9898\u6a21\u677f\u9002\u5f53\u4f4d\u7f6e\u5373\u53ef\uff0c\u5176\u4e2d\u7684\u6570\u5b57100\u53ef\u4ee5\u63a7\u5236\u663e\u793a\u6570\u91cf\u3002 \u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u6309\u8bc4\u8bba\u6570\u91cf\u663e\u793a\u524d100\u540d\u8bc4\u8bba\u8005\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18],"tags":[],"class_list":["post-30346","post","type-post","status-publish","format-standard","hentry","category-cms"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/30346","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=30346"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/30346\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=30346"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=30346"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=30346"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}