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?
- How to Remove all Instances of edit_post_link
- Remove “Insert from URL” link in Media upload – WP 3.5
- Proper use of Output Buffer
- Does My Child-Theme Functions.php Need if{die} Security In It? [duplicate]
- Should I write a PHP function in home.php?
- Edit tag cloud widget number
- function_exists call in function.php
- Debugging an error: wp_enqueue_style was called incorrectly
- How to log out everywhere else, destroy all sessions “all other devices”?
- the_post_thumbnail() based on the Post ID
- Allow authors to post only in categories they create in WordPress
- Hide a menu-item and its submenus and display a ‘Log in’ link if the user is logged out
- PHP Script within wordpress theme
- Changing the HTML Of the content
- if has theme mod
- How to override a non pluggable and non hookable function in a WordPress parent theme?
- Count Title and Post Characters
- Remove css styles from specific page
- How to remove this function from the homepage?
- Custom plugin issue when trying to use the shortcode twice on a page [closed]
- Logout and redirect using the WP Menu
- Check if current page is wp-admin
- HTML table from shortcode with multiple parameters
- Using PHP to toggle stylesheet and header image, set in cookie
- Automatically generate Post/Page from searched Database item?
- Insert all post IDs in new database table
- Nested shortCode functions in the functions.php file
- Show only IF not Google bot [closed]
- How the functions in WP are called in tags
- How to speed up admin-ajax.php in wordpress
- My Own layout in WooCommerce pages [closed]
- Add a plugin before main container
- Woocommerce – remove product from category
- Differences when using the the_time and the_date functions
- Add a Second Menu to a theme that only support 1 menu
- Custom excerpt function re-factoring
- Limit get_pages to only show 5 items
- Add itemprop Schema.org Markup to li Elements in wp_nav_menu
- Using Multiple Submit buttons to trigger customised php functions
- How does this WordPress Plugin (Thrive Comments) apply their custom comment sort? [closed]
- How to get specific image in media library with php
- Insert a button on a page with random number generation
- get current product name in functions.php
- Displaying the Month and Year that a page was Created?
- Only Show Link If div Exists
- How to style options page in dashboard?
- How to access global variable $menu inside a class function
- Sort query_posts for Parent Pages to menue order or the count?
- Change the WP Video Shortcode Output
- How to pick the default selected value in wordpress dropdown?
- Using WP-API and SSE not authenticating user ID
- Validate functions before inserting then into functions.php
- How to retrieve current wordpress profile page URL?
- Why ajax doesn’t work on certain wordpress hooks?
- Print last modified date only on posts
- WooCommerce: How can I get orders with a custom ID in order meta data object?
- Modify function to print tags/categories/exclude tags/categories/ number of posts
- Search not showing all results
- Get the date of the className or classID
- Skt full width basic slideshow problem
- $wpdb->wp_users returning empty value for
- WordPress Custom field Colors
- Woocommerce – Exclude variation attribute on specific variation