{"id":399,"date":"2014-02-05T15:02:42","date_gmt":"2014-02-05T15:02:42","guid":{"rendered":"http:\/\/www.webmastersun.com\/blog\/?p=399"},"modified":"2014-02-10T13:06:55","modified_gmt":"2014-02-10T13:06:55","slug":"how-to-display-most-commented-posts-in-wordpress","status":"publish","type":"post","link":"https:\/\/www.webmastersun.com\/blog\/how-to-display-most-commented-posts-in-wordpress\/","title":{"rendered":"How to Display Most Commented Posts in WordPress"},"content":{"rendered":"<p><a href=\"https:\/\/www.webmastersun.com\/blog\/wp-content\/uploads\/2014\/02\/wordpress-most-commented-posts.png\"><img loading=\"lazy\" class=\"size-full wp-image-400 alignleft\" alt=\"wordpress-most-commented-posts\" src=\"https:\/\/www.webmastersun.com\/blog\/wp-content\/uploads\/2014\/02\/wordpress-most-commented-posts.png\" width=\"250\" height=\"230\" \/><\/a>In WordPress to display the most commented posts there are many plugins to do this. Using these codes can help accelerate your WordPress site and then display them on the page anywhere easily.<\/p>\n<p><strong>Method 1 : Using the loop<\/strong><br \/>\nAllows you to use the WordPress loop to retrieve the articles that have the most comments . Copy the following code into your template to do this:<\/p>\n<pre>&lt;ul&gt;\r\n&lt;?php\r\n$most_commented = array('posts_per_page' =&gt; 10,\r\n'orderby' =&gt; 'comment_count',\r\n'order' =&gt; 'DESC');\r\n?&gt;\r\n&lt;?php query_posts($most_commented); ?&gt;\r\n&lt;?php while (have_posts()) : the_post(); ?&gt;\r\n&lt;li&gt;&lt;a href=\"&lt;?php the_permalink() ?&gt;\"&gt;&lt;?php the_title(); ?&gt;&lt;\/a&gt;&lt;\/li&gt;\r\n&lt;?php endwhile;?&gt;\r\n&lt;\/ul&gt;<\/pre>\n<p><strong><br \/>\nMethod 2 : Using get_posts<\/strong><\/p>\n<p>This is my favorite method, its simple, compact and easy to edit:<\/p>\n<pre>&lt;ul&gt;\r\n&lt;?php\r\n$most_commented = array(\r\n'posts_per_page' =&gt; 10,\r\n'orderby' =&gt; 'comment_count',\r\n'order' =&gt; 'DESC'\r\n);\r\n$recentposts = get_posts($most_commented);\r\nforeach ($recentposts as $post) : setup_postdata($post);?&gt;\r\n&lt;li&gt;&lt;a href=\"&lt;?php the_permalink() ?&gt;\"&gt;&lt;?php the_title(); ?&gt;&lt;\/a&gt;&lt;\/li&gt;\r\n&lt;?php endforeach; ?&gt;\r\n&lt;\/ul&gt;<\/pre>\n<p><strong><br \/>\nMethod 3 : Display most commented posts by category<\/strong><\/p>\n<p>With this method you&#8221;re only need to add a category_name argument .<\/p>\n<pre>&lt;?php\r\n$most_commented = array(\r\n'posts_per_page' =&gt; 10,\r\n'orderby' =&gt; 'comment_count',\r\n'order' =&gt; 'DESC',\r\n'category_name' =&gt; 'Category Name' \r\n\/\/ instead Category Name by your real category name\r\n);\r\n?&gt;<\/pre>\n<p>Note that the above code is only suitable for WordPress 2.9 or higher , if you are using an older version you should update to the latest version before applying these codes . Good Luck !<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In WordPress to display the most commented posts there are many plugins to do this. Using these codes can help accelerate your WordPress site and then display them on the page anywhere easily. Method 1 : Using the loop Allows you to use the WordPress loop to retrieve the articles that have the most comments [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":400,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[58],"tags":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v17.4 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to Display Most Commented Posts in WordPress - Webmaster Sun Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.webmastersun.com\/blog\/how-to-display-most-commented-posts-in-wordpress\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Display Most Commented Posts in WordPress - Webmaster Sun Blog\" \/>\n<meta property=\"og:description\" content=\"In WordPress to display the most commented posts there are many plugins to do this. Using these codes can help accelerate your WordPress site and then display them on the page anywhere easily. Method 1 : Using the loop Allows you to use the WordPress loop to retrieve the articles that have the most comments [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.webmastersun.com\/blog\/how-to-display-most-commented-posts-in-wordpress\/\" \/>\n<meta property=\"og:site_name\" content=\"Webmaster Sun Blog\" \/>\n<meta property=\"article:published_time\" content=\"2014-02-05T15:02:42+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2014-02-10T13:06:55+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.webmastersun.com\/blog\/wp-content\/uploads\/2014\/02\/wordpress-most-commented-posts.png\" \/>\n\t<meta property=\"og:image:width\" content=\"250\" \/>\n\t<meta property=\"og:image:height\" content=\"230\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Tommy\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.webmastersun.com\/blog\/#website\",\"url\":\"https:\/\/www.webmastersun.com\/blog\/\",\"name\":\"Webmaster Sun Blog\",\"description\":\"Blogging Tips to help you make money online\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.webmastersun.com\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/www.webmastersun.com\/blog\/how-to-display-most-commented-posts-in-wordpress\/#primaryimage\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/www.webmastersun.com\/blog\/wp-content\/uploads\/2014\/02\/wordpress-most-commented-posts.png\",\"contentUrl\":\"https:\/\/www.webmastersun.com\/blog\/wp-content\/uploads\/2014\/02\/wordpress-most-commented-posts.png\",\"width\":250,\"height\":230},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.webmastersun.com\/blog\/how-to-display-most-commented-posts-in-wordpress\/#webpage\",\"url\":\"https:\/\/www.webmastersun.com\/blog\/how-to-display-most-commented-posts-in-wordpress\/\",\"name\":\"How to Display Most Commented Posts in WordPress - Webmaster Sun Blog\",\"isPartOf\":{\"@id\":\"https:\/\/www.webmastersun.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.webmastersun.com\/blog\/how-to-display-most-commented-posts-in-wordpress\/#primaryimage\"},\"datePublished\":\"2014-02-05T15:02:42+00:00\",\"dateModified\":\"2014-02-10T13:06:55+00:00\",\"author\":{\"@id\":\"https:\/\/www.webmastersun.com\/blog\/#\/schema\/person\/441faf493750eb1507f97d50ea9cd742\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.webmastersun.com\/blog\/how-to-display-most-commented-posts-in-wordpress\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.webmastersun.com\/blog\/how-to-display-most-commented-posts-in-wordpress\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.webmastersun.com\/blog\/how-to-display-most-commented-posts-in-wordpress\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.webmastersun.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Display Most Commented Posts in WordPress\"}]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.webmastersun.com\/blog\/#\/schema\/person\/441faf493750eb1507f97d50ea9cd742\",\"name\":\"Tommy\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/www.webmastersun.com\/blog\/#personlogo\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/b17c25a7f242f8dc0328ed5929c512fd?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/b17c25a7f242f8dc0328ed5929c512fd?s=96&d=mm&r=g\",\"caption\":\"Tommy\"},\"url\":\"https:\/\/www.webmastersun.com\/blog\/author\/admin\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Display Most Commented Posts in WordPress - Webmaster Sun Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.webmastersun.com\/blog\/how-to-display-most-commented-posts-in-wordpress\/","og_locale":"en_US","og_type":"article","og_title":"How to Display Most Commented Posts in WordPress - Webmaster Sun Blog","og_description":"In WordPress to display the most commented posts there are many plugins to do this. Using these codes can help accelerate your WordPress site and then display them on the page anywhere easily. Method 1 : Using the loop Allows you to use the WordPress loop to retrieve the articles that have the most comments [&hellip;]","og_url":"https:\/\/www.webmastersun.com\/blog\/how-to-display-most-commented-posts-in-wordpress\/","og_site_name":"Webmaster Sun Blog","article_published_time":"2014-02-05T15:02:42+00:00","article_modified_time":"2014-02-10T13:06:55+00:00","og_image":[{"width":250,"height":230,"url":"https:\/\/www.webmastersun.com\/blog\/wp-content\/uploads\/2014\/02\/wordpress-most-commented-posts.png","type":"image\/png"}],"twitter_misc":{"Written by":"Tommy","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebSite","@id":"https:\/\/www.webmastersun.com\/blog\/#website","url":"https:\/\/www.webmastersun.com\/blog\/","name":"Webmaster Sun Blog","description":"Blogging Tips to help you make money online","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.webmastersun.com\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"ImageObject","@id":"https:\/\/www.webmastersun.com\/blog\/how-to-display-most-commented-posts-in-wordpress\/#primaryimage","inLanguage":"en-US","url":"https:\/\/www.webmastersun.com\/blog\/wp-content\/uploads\/2014\/02\/wordpress-most-commented-posts.png","contentUrl":"https:\/\/www.webmastersun.com\/blog\/wp-content\/uploads\/2014\/02\/wordpress-most-commented-posts.png","width":250,"height":230},{"@type":"WebPage","@id":"https:\/\/www.webmastersun.com\/blog\/how-to-display-most-commented-posts-in-wordpress\/#webpage","url":"https:\/\/www.webmastersun.com\/blog\/how-to-display-most-commented-posts-in-wordpress\/","name":"How to Display Most Commented Posts in WordPress - Webmaster Sun Blog","isPartOf":{"@id":"https:\/\/www.webmastersun.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.webmastersun.com\/blog\/how-to-display-most-commented-posts-in-wordpress\/#primaryimage"},"datePublished":"2014-02-05T15:02:42+00:00","dateModified":"2014-02-10T13:06:55+00:00","author":{"@id":"https:\/\/www.webmastersun.com\/blog\/#\/schema\/person\/441faf493750eb1507f97d50ea9cd742"},"breadcrumb":{"@id":"https:\/\/www.webmastersun.com\/blog\/how-to-display-most-commented-posts-in-wordpress\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.webmastersun.com\/blog\/how-to-display-most-commented-posts-in-wordpress\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.webmastersun.com\/blog\/how-to-display-most-commented-posts-in-wordpress\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.webmastersun.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How to Display Most Commented Posts in WordPress"}]},{"@type":"Person","@id":"https:\/\/www.webmastersun.com\/blog\/#\/schema\/person\/441faf493750eb1507f97d50ea9cd742","name":"Tommy","image":{"@type":"ImageObject","@id":"https:\/\/www.webmastersun.com\/blog\/#personlogo","inLanguage":"en-US","url":"https:\/\/secure.gravatar.com\/avatar\/b17c25a7f242f8dc0328ed5929c512fd?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/b17c25a7f242f8dc0328ed5929c512fd?s=96&d=mm&r=g","caption":"Tommy"},"url":"https:\/\/www.webmastersun.com\/blog\/author\/admin\/"}]}},"_links":{"self":[{"href":"https:\/\/www.webmastersun.com\/blog\/wp-json\/wp\/v2\/posts\/399"}],"collection":[{"href":"https:\/\/www.webmastersun.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.webmastersun.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.webmastersun.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webmastersun.com\/blog\/wp-json\/wp\/v2\/comments?post=399"}],"version-history":[{"count":0,"href":"https:\/\/www.webmastersun.com\/blog\/wp-json\/wp\/v2\/posts\/399\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.webmastersun.com\/blog\/wp-json\/wp\/v2\/media\/400"}],"wp:attachment":[{"href":"https:\/\/www.webmastersun.com\/blog\/wp-json\/wp\/v2\/media?parent=399"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webmastersun.com\/blog\/wp-json\/wp\/v2\/categories?post=399"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webmastersun.com\/blog\/wp-json\/wp\/v2\/tags?post=399"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}