Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?

share|improve this question
1  
If you have access to PHPMyAdmin, you could do what this page suggests. –  Mike Madern Jan 11 '13 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 '13 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 '13 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 '13 at 14:20

1 Answer 1

up vote 1 down vote accepted

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.

<?php
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;
exit();
share|improve this answer
    
Im out for something like option 3. Im gonna try and get back to you. Thank you meanwhile. –  M3o Jan 22 '13 at 12:13
    
Didint get it to work thou. I cant understand why the plugin in firsthand i not working. –  M3o Jan 31 '13 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 '13 at 15:55

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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