It looks like you could add the
MAX( comment_date ) last_commented_date
to the field list to get the latest date, each user commented.
Then use e.g. the human_time_diff()
function to get a human readable text for how long ago each user commented.
human_time_diff( strtotime( $result->last_commented_date) )
For safety reasons, you should then prepare the SQL statement with $wpdb->prepare()
, since it contains the user input $amount
.
Related Posts:
- Pre_get_comments and orderby comment_karma
- the_date() not working
- Query multiple custom post types in single loop
- The correct method to pass query vars in AJAX using ajaxurl
- How to search display_name column when using WP_User_Query
- wpdb::prepare was called incorrectly
- Using WP_Query – how to display something IF there are no results
- How to order WP_User_Query results to match the order of an array of user IDs?
- Display user’s total comment count outside The Loop
- Facebook Comment Count
- Alter query on edit.php
- Getting the comment number relative to all the post’s comments
- How to output a permanently delete comment link?
- How to find objects by terms
- How to create a WP_Query to search the Title or Tag?
- count number of user comments with a specific comment meta value
- Change comments form title on a page by page basis
- How to order posts by modified date without using ‘query_posts’?
- Delete post revisions on post publish
- How to get user by display_name with WP_User_Query
- How to sort results from a custom database table
- Specific Loop For 2 Within Each
- How do I make wordpress comment fields required?
- How do I create comment-reply-button using element not
- How to check if comments are paginated?
- WP database error for comments_popup_link()
- How to add a post or page tag to the list of classes appearing in the body tag’s class attribute?
- Use two WP Query in template
- my function doesn’t return my post from today
- Notify WordPress Site I Have Linked To Them
- Add “last” and “first” to WordPress Comment Pagination Links
- Uncaught TypeError: Cannot read property ‘firstChild’ of null after upgrading to WordPress 5.5
- Display related products with custom output
- Replace comment avatars and links at the same time
- How can i limit the number of posts to the most recent 6 in my query?
- Closing Comments conditionally in comments.php
- Why does a header location on admin_head remove the query var I’m setting in the location?
- getting the values of hidden inputs to use them in a php mysql query
- Offset with ajax load more posts duplicates
- wordpress query returning unexpected results
- How to add delete, approve, spam Links to Comments
- Let user select the number of posts shown per page jquery error
- Query doesn’t display text data with apostrophes
- Real time notification on user profile after new comment
- How to query a staging database?
- How to make a parent page for author.php?
- How to do a MySql query in WordPress?
- What’s the correct offset value for order ASC?
- Pagination in WP Queries
- How can I output the slug of a comment author?
- How can I enqueue comment-reply script only on certain page?
- How can I display a query in a page?
- Include a custom field in mysql query
- Echo multiple tasks if a common function exists
- Get posts associated with media attachment
- How to enqueue assets only on queried pages, excluding the page being queried?
- Getting most popular posts based on Facebook comments count
- A Space being added to url generated by custom plugin
- “Where… like” query not working as expected
- Unserializeing multiple column values that are stored in one database results variable
- Check if values exists DB
- Trying to exclude posts from a category on the home page
- Problems With Query and/or Template Part and/or PHP
- If Elseif Query
- WordPress – show number of comments for each post in widget
- Arrange Category post manually when displayed
- How does add_action ‘comment_post’ work?
- Get first comment link on the post itself
- How to callback custom field text
- Custom action on comment post
- WordPress most commented posts of last X days
- How can I add more code to this?
- The search engine of my website finds only posts and not pages, how can I solve this problem?
- Does wp_query and query_posts affect website performance? [duplicate]
- How do I call comments_template(); from a plugin file?
- Hide empty categories from get_categories
- How to get the rating value of each comment
- Query Concatenation
- Trouble figuring out how to get my button to submit comment
- How to insert a variable into a query parameter?
- How to convert my comment.html to comment.php
- wp_query on search results page showing all results every time
- WP_Query not returning results
- Show post like this image in my newssite [closed]
- Can WordPress support Website (19GB database) Should I move Our WordPress Website to a custom one using Laravel or any other PHP framework?
- Sorting a custom post type in pre_get_posts
- Three different queries on same page
- Guests comment form – prevent duplicate email addresses
- SQL query to retrieve the number of WordPress posts with all given categories
- Permissions error when I use my plugin to delete comments in the front-end
- Exclude a category ID from the following function
- Custom Filtering date with newsletter
- taxonomy pages returning “NULL” when running default WordPress function ‘get_queried_object()’
- Hot to show custom post type taxonomies on archive page
- Display featured posts first, then display all others within a specific category in WordPress
- Remove links to the comments section
- Function wpdb::prepare was called incorrectly. The query argument of wpdb::prepare() must have a placeholder
- Issues applying JSON body filters in EU F&T Portal SEARCH API with WordPress integration
- Removing website URL in comments causes misalignment of submit button and tickbox
- How to allow searching a custom meta key in admin list table?