We are now ready to display the comments we entered on our wall. They are already saved in the WordPress database, so just we need to extract and show them on our widget.
We will also create a mechanism to reload the comments automatically when the user submits the form.
Add a new function,
WPWall_ShowComments()
at the end ofwp-wall.php:
function WPWall_ShowComments() { global $wpdb; // get our page id $options = get_option('wp_wall'); $pageId=$options['pageId']; // number of comments to display $number=5; $result=''; commentsdisplaying// get comments from WordPress database $comments = $wpdb->get_results ("SELECT * FROM $wpdb->comments WHERE comment_approved = '1' AND comment_post_ID=$pageId AND NOT (comment_type = 'pingback' OR comment_type = 'trackback') ORDER BY comment_date_gmt DESC LIMIT $number "); if ( $comments ) { // display comments one by one foreach ($comments as $comment) { $result.= '<p><span...