false, // Include password protected posts? 'showpings' => false, // Include pingbacks and trackbacks? 'post_types' => array( 'post', 'page' ), // Array of post types to use 'post_statuses' => array( 'publish', 'static' ), // Array of post statuses to include // Standard get_comments() args 'number' => 5, 'status' => 'approve', // Hide comments in moderation ); $most_recent_comments_args = wp_parse_args( $args, $defaults ); // Create the cache key $key = md5( serialize( $most_recent_comments_args ) ); $last_changed = wp_cache_get( 'last_changed', 'comment' ); if ( ! $last_changed ) { $last_changed = time(); wp_cache_set( 'last_changed', $last_changed, 'comment' ); } $cache_key = "most_recent_comments:$key:$last_changed"; // Check to see if we already have results for this request if ( $cache = wp_cache_get( $cache_key, 'comment' ) ) { return $cache; } // Modify the get_comments() SQL query add_filter( 'comments_clauses', '_mrc_modify_comments_clauses' ); // Get the comments // The custom arguments will be ignored by get_comments() $comments = get_comments( $most_recent_comments_args ); // Remove the get_comments() SQL query filter remove_filter( 'comments_clauses', '_mrc_modify_comments_clauses' ); // Cache these results wp_cache_add( $cache_key, $comments, 'comment' ); return $comments; } // Output an unordered list (