I want to export my comments to Excel, PDF or Word. The format really doesn't matter, I just want them exported.

I tried the Export Comments plugin, the standard one, but couldn't get it to work, I have to do it manually.

Anyone can suggest something on this topic?

  • 2
    If you have access to PHPMyAdmin, you could do what this page suggests. Jan 11, 2013 at 13:53
  • Very helpful! The idea behind it is that any user on the network as an "Admin" could export. With that I mean that it should be as easy as possible.
    – M3o
    Jan 11, 2013 at 13:58
  • @MikeMadern, this seems not to have been asked before here, would be nice if you assembled an Answer. Not a copy/paste from the link, but one screenshot, a couple of sentences and voilà!
    – brasofilo
    Jan 11, 2013 at 13:58
  • It wasnt really the answer, what i wanna do is to make it easy for an unedicated user to export comments from wp-admin.
    – M3o
    Jan 11, 2013 at 14:20
  • You can try this simple plugin to export wordpress comments
    – mujuonly
    Nov 23, 2023 at 10:13

1 Answer 1


Option 1

As the article linked by @MikeMadern suggests:

  • in your web host control panel, go to PHPMyAdmin

  • select the table wp_comments

  • select Export, configure the format

    export mysql

  • further down in the same screen, select the Save as file and Go

    enter image description here

Option 2

Or, as the same article suggests, just use a plugin:

Export comments

Pulls comments out of your WordPress database for backups or analysis.

If you have WP_DEBUG enabled, the plugin dumps a couple of warnings, but it's nothing critical, and it works as expected.

Option 3

Just retrieved an old script and adapted to WordPress (using the query from Export Comments as example). Put the file in the root of WP installation and access directly, it will export an Excel file with the comments.

It would be much better to have this as a plugin with security checks and all.
Remove from server after using. Or maybe put it in a folder as index.php and set an .htaccess password.

define( 'WP_USE_THEMES', false );
require( './wp-load.php' );

global $wpdb;
$query = "SELECT * FROM $wpdb->comments 
    WHERE 1 = 1 
    AND ( comment_approved = '1' OR comment_approved = '0' ) 
    ORDER BY comment_ID DESC";

$error = "Error: the query failed...
    <pre style='width:700px;word-wrap:break-word;white-space:normal;'>$query</pre>";

$result = $wpdb->get_results( $query, ARRAY_A ) or wp_die( $error );

$header = array_keys( $result[0] );
$html = array();
$html[] = "<tr><td>" .implode( "</td><td>", $header ) . "</td></tr>";

foreach( $result as $row )
    $html[] = "<tr><td>" .implode( "</td><td>", $row ) . "</td></tr>";

$html = "<table>" . implode( "\r\n", $html ) . "</table>";

$fileName = 'Comments_' . date("Ymd") . '.xls';
header( "Content-type: application/vnd.ms-excel" ); 
header( "Content-Disposition: attachment; filename=$fileName" );

echo $html;
  • Im out for something like option 3. Im gonna try and get back to you. Thank you meanwhile.
    – M3o
    Jan 22, 2013 at 12:13
  • Didint get it to work thou. I cant understand why the plugin in firsthand i not working.
    – M3o
    Jan 31, 2013 at 14:50
  • @MeiasSafa, what didn't work? How did you test the code? Any error messages? Was the path to wp-load.php correct? What if you disable the header() commands?
    – brasofilo
    Jan 31, 2013 at 15:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.