Note that the function wp_list_comments()
doesn’t fetch the comments, only displays them in various ways depending on the input arguments.
You’re actually using the WP_Comment_Query
/get_comments
input arguments into wp_list_comments()
.
You could try this instead:
$postID = 12345; // Adjust this!
$comments = get_comments(
[
'date_query' => [
'after' => '5 minutes ago',
'inclusive' => true,
],
'post_id' => $postID,
'status' => 'approve',
]
);
printf(
'<ol>%s<ol>',
wp_list_comments( $args = [ 'echo' => 0 ], $comments )
);
where you can play with the comment output through the $args
input array.
Check the Codex here.
Note that we can skip the before
attribute when we use after
attribute.
Related Posts:
- WP_Comment_Query pagination, delving into the unknown
- Exclude comments from a WP_Query object?
- Get posts with condition on comment meta value
- WP_Query sort by comment meta data
- Get number of comments after modifying comment query
- using wp_query to return posts w/ comment count > 0
- How to target the default Recent Posts and Recent Comments widgets with pre_get_posts?
- Query posts with more than 20 comments
- Sorting posts DESC based on the number of comments using WP_Query
- Most commented last 24h, week, month, year and all time – posts_where
- Most commented post showing 2 records
- WordPress Comments sort by custom meta key
- Query posts by last comments
- How to list posts with disabled/closed comments, with pagination?
- I need help using pre_get_comments to limit comments in the comments admin screen
- All Posts Have The Same Comments
- prevent get_comments() from returning comments not in comment__in
- Is it possible to give a classname to specific comments in the WordPress admin?
- How to get_comments() ordered by date and parent?
- Comments orderby comment date not working
- How to display comments list by order when clicking on newest or oldest link?
- Get comment number by date range?
- meta_query ‘compare’ => ‘IN’ not working
- Ignoring initial articles (like ‘a’, ‘an’ or ‘the’) when sorting queries?
- WP_Query and next_posts_link
- Sanitation needed for WP_Query or get_posts calls?
- how does $wpdb differ to WP_Query?
- WP_Query – filter or directly?
- replace the WP_Query class in the main query
- How can I save an array from a random post sequence for later use?
- Why is WP-Query spelled like it is?
- Limit search results to exact match
- WP_Query hit max joins… How else can I build a search function that uses custom fields?
- How to count data records in wordpress which have same meta_value in wp_postmeta table?
- Order terms inside a select dropdown
- How to speed up wp_query, took more 5s to run against 100k posts
- How to sort posts in admin by titles with dd.mm.yyyy format?
- WP_Query orderby breaks when using AJAX?
- Detect featured image among the attached images
- How do I change database charset when using `wpdb`
- WP_Query attachments by multiple IDs
- get_posts – get all posts by array of author
- wp_query not searching with apostrophe
- pre_get_posts Remove tax_query Completely
- Assigning a meta_query value based on regexp to wp_query fails
- Getting Taxonomy inside WP_Query Loop
- Nested tax_query that allows specified categories OR tags, but NOT other categories
- How to delete taxonomy term when a wordpress user is removed?
- Custom query based on meta key – Reduce three states to two in results?
- How to create a WordPress Post Filter that users can use to filter posts by year?
- WP_Query custom query showing only 10 posts on all pages
- Not getting metavalue
- Ajax load more posts – WP_Query parameters not working
- How to display multiple custom fields with the same meta_key in an ascending order?
- Using the_post_thumbnail resets current loop item ID
- Meta_query with multiple keys and multiple values
- WordPress WP_Query make mysql time out
- Assign Json file to WP_Query
- How do I query for posts by partial meta key?
- WP Query to have sticky posts first, with pagination and having a joint ‘posts per page’ arg with main loop
- New WP_Query calls Pre_get_posts filter twice
- How to increase load time of an archive/search page (WP_Query)
- Removing duplicate values between two wordpress queries
- Issue with front page navigation after upgrading to 3.4
- Ordering posts by an array
- Prevent author bio page from showing in search results
- Changing the default wp_search_stopwords
- WordPress Custom Search Form Displaying Unexpected Results
- WP_Query array key / value pairs?
- Get posts from multiple tax terms
- WP_Query offset is returning post from prevois loop
- Tax query is not working!
- Does WP_Query ‘responds’ badly to empty arguments?
- Does putting queries within loops cause an issue on WordPress?
- Reordering content using a meta value
- Adding query parameter to archive page returns 404
- Optimising WP_Query with ACF Fields
- WordPress AJAX Request returns 400
- Using wpdb prepare with a variable, turns it into a big string
- SQL to join u3g_users & u3g_meta_value with repeating data
- WP_Query no result if keyword contains number
- Order by value of Custom Field using url string
- update_post_meta performance in a loop woocommerce
- Separate by Category Post Type
- ACF: using two loops, the_field returns field content from another loop
- Combine WP_Query with array of custom data to single loop without breaking the pagination
- query_posts() doesn’t seem to be called in my page
- WP_Query with Pagination and orderby meta_value_num showing duplicates
- Optimising specific Query with ACF meta objects
- How to get several fields from wp_query?
- Slow getting posts from category
- Pagination not working with WP_Query (creates links but no page)
- WP Query posts__in not working with array
- query_posts with sorting on a custom datestamp
- Query Posts by date range with fixed beginning and end
- Is it possible to use WP Query to orderby custom meta value and custom taxonomy?
- Display all custom meta field values from the database using ACF Repeater
- Woocommerce set loop_shop_columns to be 3 in the main shop page loop only and 4 otherwise
- Get posts using multiple values from ACF checkbox as meta query wordpress
- Why ignore_sticky_posts argument is in sticky post query?