Php code to list WordPress post in csv or excel format

Write this code in sidebar.php

You can also change the file path as required. The Default file location is your domain path.

<form action='<?php echo $_SERVER[“PHP_SELF”];?>’ method=’post’>

Import File :<input type=”text” name=”file” id=”file” />
<input type=’submit’ name=’submit1′ value=’submit1′ >

$values = mysql_query(“SELECT ID, post_date, post_title, post_content,post_excerpt,post_status, post_name, post_type FROM $wpdb->posts”);
while ($rowr = mysql_fetch_row($values)) {
for ($j=0;$j<8;$j++) {
$csv_output .= “@”.$rowr[$j].”@,”;
$csv_output .= “\n”;

?> –>


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: