This is pretty easy to do. Put this code in your functions.php file.
The logic is pretty straightforward.
- Get all posts with
get_posts()
. - Iterate over all post, extract comments count and permalink of current post and
- Print out the results.
.
add_action( 'init', 'get_comments_count' ); // Hook to init, elsewhere or use directly in your code
function get_comments_count() {
$all_posts = get_posts( array( 'numberposts' => -1 ) );
foreach( $all_posts as $current_post ){
$comments_count = get_comment_count( $current_post->ID );
$permalink = get_permalink( $current_post->ID );
printf( '<a href="https://wordpress.stackexchange.com/questions/233878/%s">%s</a> - %s<br>', $permalink, $permalink, $comments_count['total_comments'] );
}
}
Related Posts:
- Multiple is_page() in page.php
- class=”parent” for wp_list_pages?
- Change comments form title on a page by page basis
- add_rewrite_rule with bottom priority doesn’t handle the WordPress pages
- How do I create comment-reply-button using element not
- Listing all sub-pages?
- Replace comment avatars and links at the same time
- Adding ads code between comments
- syntax issue on php 7.4
- How do I fetch all comments per post via WP REST API?
- How do I publish only one page to production after making changes on staging?
- Can’t load WP function into external function
- comments_number display outside specified span
- Can’t get page content in WordPress
- Way to querry data (tags) from a wordpress database?
- Ajax load more button for comments wordpress
- Populate editor with some content of a page with a page template
- Limit 1 global comment per minute
- wp-comments-post.php file returns a blank page
- php function to display commenter username or login
- Alter required message using comment form api
- Inject class in body when particular page template is used
- Use .php file as page instead of wordpress page & template file?
- Use WordPress function in php file
- How to use theme function in post/page?
- Send a mail to specific address in a custom field when a new comment is made on a specific post
- Need php code’s output to display underneath a Divi Module
- Fetching Initials of the Commentator in the WordPress Website
- PHP Output also in Child theme, but different
- How to Display a List of Child Pages For a Parent Page in WordPress
- A function to get the content of a page
- comment_post (if comment is approved OR $comment_approved === 1) not working?
- Show all people who commented on all posts by an author
- Getting page / post URL on publish and / or update
- How to get the rating value of each comment
- Trouble figuring out how to get my button to submit comment
- How to return a Boolean for a page that is a subpage thru its name?
- Removing website URL in comments causes misalignment of submit button and tickbox
- Insert a button on a page with random number generation
- Custom location for attached images
- Show comments menu in dashboard only if the site has comment
- WooCommerce – Reset quantity input field when variation changes
- Query all posts of a custom taxonomy term
- get current product name in functions.php
- Get first URL from post content
- Setting custom canonical urls
- Handling Body class based on Template
- Trigger popup in a php if/else statement
- Setting a cookie upon specific URL visit
- Get_avatar filter?
- WordPress child theme fails to override parent navigation menu in /inc/structure/header.php
- get post based on category chosen in drop down – The ajax method
- Adding Default Settings to Theme My Login plugin
- Image as Sales Badge
- Global variable $post returning incorrect object
- how to make separate field in wordpress user_data_
- Function not working at one place
- How can I load a PHP page without using a Template?
- jQuery not defined
- Displaying the Month and Year that a page was Created?
- Changing custom logo link
- Add a class to the anchor tag on HTML5 gallery
- Conditional Header in wordpress
- Remove meta description on certain pages
- Menu — How to add “current-menu-grand-ancestor” css class
- Use menu link or onClick to set a variable
- Swapping wp_dropdown_categories function with wp_category_checklist
- functions.php is being included twice, creating PHP fatal errors
- Hide Hamburger Menu On Specific Page (Front Page/Home Page)
- Automatically remove a canceled order in Woocommerce
- Display fields as values in array from external SQL DB
- Only Show Link If div Exists
- How to put a variable in a instance in the widget
- Create another “Display Site Title and Tagline” checkbox, “Header Text Color” setting and control
- Trying to establish connection to External Database
- add_action shortcut?
- Passing the custom field values in the wp_get_current_user array function
- Best practice for migration friendly images in posts/pages?
- Using fwrite() and “a” appends multiple times instead of once
- How to output a PHP file values by shortcode?
- Showing content from one page on another
- How to style options page in dashboard?
- How to insert a single row to WP database table?
- Get date numerical and separate?
- Where in PHP do I move title and meta (date) to bottom of each blog section?
- WSoD being caused by this piece of code
- “comments.php” not available after edit in WP administration
- Converting HTML Template to WordPress Theme
- Set the background to a default image if there isn’t a specified “featured image”
- How to Arrange PHP Files to Allow for Multiple Types of Pages?
- Add a variable in functions.php and call it in single.php
- How to access global variable $menu inside a class function
- Calling directories to load in wordpress
- WordPress add post format support not working
- Can I prevent the user from adding more than two levels deep of terms inside of a taxonomy metabox?
- Page Automatically Generated from Theme?
- Image media upload metabox
- User’s total comment count excluding comments on their own posts
- How to remove the cufon script from Dzonia Lite theme [closed]
- How to remove or change the “W” icon in “My Sites”?