<?php
$recent_comments = get_comments( array(
'number' => 1,
'status' => 'approve'
) );
foreach($recent_comments as $comment) :
$latest_postid_with_comment = $comment->comment_post_ID;
endforeach;
?>
Probably way to compress this code into something smaller. But this will work.
Related Posts:
- Get page ID of page that is set as the posts page
- How to make comments work for a post loaded per Ajax?
- Are post ID’s reliable?
- Get current post id in functions.php
- get all posts ID from a category
- Allow variable amount of comments before pagination
- Get the current post ID as a variable in Javascript
- Is post ID number always incremental n+
- get comments and get posts in loop
- How to display comments and comment form on custom post type?
- Comments are assigned to wrong or related post
- Are all ID’s used unique?
- How can I allow editors to leave comments on posts that have not yet been published?
- Update post date on every new comment?
- $post->ID displays wrong ID
- One comment per user email per post
- Can’t show comments count per post outside loop
- At my posts archive page, outside the loop, get_the_id() returns the top most post’s ID
- Only display posts with comments
- Comments enabled, but disabled at the same time
- Comments not showing in custom post type – WordPress
- How to output comments number of a post per day?
- Enable commenting on front-end preview page for pending posts
- Showing random content / pictures from earlier posts in a sticky post?
- Hide comments awaiting moderation from user who submitted the comments
- Get the post_id of a new post
- get post id in while loops outputting page id
- How can I display a specific user’s first published post?
- Undefined variable post_id in custom quick edit coloumn
- Hide Post comments when displayed via WP_Query
- Including new Javascript only after a comment is made
- Disable Post/Page comment emails for creators
- Display posts with comments closed, with pagination?
- Getting post id from wp_insert_post_data function?
- Why is WordPress redirecting users to random posts after commenting?
- Does an article (post) id ever change?
- How to get most recent commented post above new submitted post in WordPress?
- How to get the post’s parent ID?
- Can a page_id and a post_id be same?
- When trashing a post, also trash related comments
- Is there a better, more efficient way to get the post id outside the loop?
- how to find user ids of all commenters in a post
- Diplay comment date on WP_Post_Comments_List_Table
- Getting current post ID in functions.php
- Buddypress activity id
- Posts vs. Pages
- count the total number of comments the user has received for his published posts
- How blog page in WordPress works : blog page retrieve first post ID
- How to Orderby Comments by post title?
- Post-ID in url differs from $post->ID
- Get post slug and match with menu item slug to change css
- WordPress Post ids big increment
- Reuse old post ID for new post after deleting post
- Remove the URL author of post on all comments
- Get post attachment with post id
- WordPress weird behaviour on comments
- Comments are in database, don’t show up in WordPress backend or frontend
- No comments allowed
- I want to change the WordPress comments file
- How can i take all ids from untrash_post action?
- How do I apply a wordpress function to something with no ID inside an archive page?
- Get from the dashboard the ID of the current post being edited
- Only get post_id [duplicate]
- Posting a comment redirects admin/users to blank page
- Surrogate ID for posts, is there an alternative field in the posts table?
- How to enable comments meta box for other author posts?
- Is it possible to have dynamic post id # in add_menu_page()?
- Comments as part of a post
- Some comment box wordpress in 1 post [closed]
- No comments on static front page
- 3rd Party Login in wordpress
- Trash a post, send associated comments into the trash bin (change status)
- Using Post ID and Page ID in same function
- Apply comment to different post (not the current post) [duplicate]
- How can I get a comment ID on Submit?
- External link not showing on post but showing on comment
- Get first comment link on the post itself
- Get url/link to latest comments in a post
- Display only posts with comments
- unused post IDs
- wp_query select if have comments
- Display the first post’s comments of category in comments.php template
- 2 tick boxes appearing below comments
- How to display a certain template element only for posts published within certain time range?
- Admin moderates ALL comments (including post author)
- Show List of Posts With Comments Open
- Custom post page has attributes of latest post [closed]
- Can I get custom post items in select box (dropdown)
- How can I show the positive and negative comments for a same post separately?
- How does WordPress add the comments and comment form to posts
- What is $post->ID
- View post with specific category id and name which I selected in the backend (drop-down option)
- How to update wp_posts with just the returned comment count from wp_comments (SQL GROUP BY)
- Simple shortcode to check if a user has commented on a certain post
- Undefined Function Fatal Error with Shortcode [closed]
- How to get post ID after removing that post?
- Best method for comment section associated with different images?
- post comment dont show the pdf file wordpress
- Why does ‘get_the_ID’ work outside of the loop?
- Comment count next to post title?