• I’m using the Starker’s html5 theme and there is a widget that lists the 5 most recent comments from all posts on the site. I would like to hard code this feature into a new page and I can’t seem to figure out the code.

Viewing 2 replies - 1 through 2 (of 2 total)
  • are you familiar with page templates?
    http://codex.wordpress.org/Pages

    get_comments()
    http://codex.wordpress.org/Function_Reference/get_comments

    also, the code of the ‘recent comments widget’ is in /wp-includes/default-widgets.php about line 620;
    the essential code there is:

    $comments = get_comments( apply_filters( 'widget_comments_args', array( 'number' => $number, 'status' => 'approve', 'post_status' => 'publish' ) ) );
    		$output .= '<ul id="recentcomments">';
    		if ( $comments ) {
    			foreach ( (array) $comments as $comment) {
    				$output .=  '<li class="recentcomments">' . /* translators: comments widget: 1: comment author, 2: post link */ sprintf(_x('%1$s on %2$s', 'widgets'), get_comment_author_link(), '<a href="' . esc_url( get_comment_link($comment->comment_ID) ) . '">' . get_the_title($comment->comment_post_ID) . '</a>') . '</li>';
    			}
     		}
    		$output .= '</ul>';

    hope this helps 😉

    Thread Starter ScottyChoc

    (@scottychoc)

    Thanks so much for the quick response! I will get to work on this…

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘List recent comments from all posts’ is closed to new replies.