<?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?
- Get current post id in functions.php
- 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?
- 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
- Enable commenting on front-end preview page for pending posts
- get post id in while loops outputting page id
- Undefined variable post_id in custom quick edit coloumn
- Disable Post/Page comment emails for creators
- 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?
- 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
- How blog page in WordPress works : blog page retrieve first post ID
- Post-ID in url differs from $post->ID
- How to allow logged in users to post anonymously
- current post with current author
- How to get next post ID?
- Enable Comments Box On Custom Post Type
- Turn On Comments On Custom Post Types in Directory Theme
- Emojis replaced by ‘?’ automatically
- A friend wants to make a comment on one of my articles, she has to be logged to wordpress?
- Is it possible to paste a link without tags and make it directly a link in a post?
- Showing author page if user has no post
- Customizing Comments on Posts
- WordPress Comment posting problem
- What do comments with […] mean?
- How to get a post’s content? [closed]
- How to get posts and comments amount per hour, per year and per month?
- Show comment number per author per day
- How to get ID of the page included with get_page()?
- How to I retrieve the ID from the Posts page?
- Crazy Question – Updating Post ID
- Howto show comment count by post in post?
- Why I can not I use the variable outside my function?
- How do you change the comment count in the back end posts list, to reflect unapproved comments, rather than all comments?
- Hide comments and posts posted by other user
- Let both the admin and post author update comment meta
- retrieve the oldest post id
- How to style archive post titles… but only those posts who have comments?
- How does WP decide how to display a page
- WP_Query custom field pass the post id
- Accessing Post ID Within Loop
- Display on page every post in blog WITH comments
- Are post, page and category IDs unique to each other?
- Showing recent post of category in page
- The loop starting at a certain ID
- linking to post outside the loop
- Widget to show posts in the sidebar basing on its IDs
- Get a post’s ID
- How to get the post id (of the parent custom custom type) in a loop inside a widget?
- How to implement a WordPress comments function?
- Count the total views of all user posts published
- how to show comments only author which send own posts in wordpress
- Shortcode for Comments and Comment Boxes in Post Loop
- Merge get_comments & get_posts into a single query
- Get post slug and match with menu item slug to change css
- 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
- Get from the dashboard the ID of the current post being edited
- Only get post_id [duplicate]
- How to enable comments meta box for other author posts?
- Comments as part of a post
- Some comment box wordpress in 1 post [closed]
- 3rd Party Login in wordpress
- Apply comment to different post (not the current post) [duplicate]
- How can I get a comment ID on Submit?
- Get first comment link on the post itself
- unused post IDs
- Display the first post’s comments of category in comments.php template
- How to display a certain template element only for posts published within certain time range?
- Custom post page has attributes of latest post [closed]
- Can I get custom post items in select box (dropdown)
- How does WordPress add the comments and comment form to posts
- 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
- How to get post ID after removing that post?
- Comment count next to post title?