Is there a simple way to get the "latest comment date" of a wordpress page?
For the page itself there is a simple solution like this:
get_the_date('Y-m-d', $post->ID)
For example this will not work for me (especially since i can't define the last comment either):
get_comment_date( 'Ymd', $post->ID);
And my array way doesnt work. The "comment_count
" is fine, but the "get_comment_date( 'd\/m\/Y' )
" is always the same date, for all pages - why?
$args = array(
'post_id' => $post->ID,
'posts_per_page' => 10,
'post_type' => 'page',
'orderby' => 'date',
'category_name' => 'MyName');
$myposts = get_posts( $args );
foreach ( $myposts as $post ) : setup_postdata( $post ); ?>
<?php echo '<div hljs-string">'d\/m\/Y' ) . '"><span>'. $comments_count .'<span></div>'; ?>
<?php endforeach; ?>
CodePudding user response:
If I understood you correctly, you're trying to get the most current comment for a specific page. So, I'd use
Let me know if that's what you were looking for!