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′ >
</form>
<?php
if(isset($_POST[‘submit1’]))
{
$fp=fopen(‘test.csv’,’a’);
$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”;
}
fwrite($fp,$csv_output);
exit;
}
?> –>