Export WordPress Posts to Excel

Create a file in your theme ‘download.php’. And the save the file with the below content.

/* Template Name: Download */
wp_head(); ?>
<table id="download">
<th>Postal Code</th>
<th>Phone No</th>
<?php $downloads = new WP_Query('showposts=-1');
while ($downloads->have_posts()): $downloads->the_post();
global $post; ?>
<td><?php the_title();?></td>
<td><?php the_permalink();?></td>
<td><?php echo get_post_meta($post->ID,'custom_field_name',true);?></td>
<td><?php $poc = get_the_terms( $post->ID, 'custom_taxonomy_name', '', ', ', '' ); $list = ''; if ($poc) { foreach ($poc as $data) $list .= $data->name.', '; echo $list; } ?></td>
<td><?php $cats = get_the_category(', '); $list = ''; if ($cats) { foreach ($cats as $data) $list .= $data->cat_name.', '; echo $list; } ?></td>
wp_reset_query(); ?>

And create a new page in your WordPress admin dashboard , with the name ‘Download’ and select the page template to ‘Download’, and keep the page has private and just view the page.

You will get the all your posts.

Just copy it and save it in XLS.


2 thoughts on “Export WordPress Posts to Excel”

  1. Hi i am also using such kind of code but the format is not correct. It’s open file in excel but not in excel format. How can i solve this problem.

Leave a Reply

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

WordPress.com Logo

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

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s