Leave a Reply

3 comments

  1. What is the SQL query you are using? What are more details of the export and end format you need?

    The obvious things are 1) http://wordpress.org/extend/plugins/navayan-csv-export/

    “Navayan CSV Export is a wordpress plugin to export all your table data in CSV (Comma Separate Value) format.”

    and 2), exporting with phpmyadmin – the database utility – into CSV. http://www.phpmyadmin.net/home_page/index.php

    phpmyadmin is usually available on web hosts. Use “Export” and then select CSV.

    phpmyadmin is also available as a plugin, though only the older versions of the plugin seem bug free: http://wordpress.org/extend/plugins/portable-phpmyadmin/

    Will either of these work?

  2. I needed to do exactly the same and found a way. With multiple joins you will get all meta_values in one row per post ID:

    SELECT 
     p.ID, p.post_content,
     p.post_title,
     p.post_excerpt, 
     pm1.meta_value as author,
     pm2.meta_value as publisher,
     pm3.meta_value as book_condition
    FROM wp_posts p
    LEFT JOIN wp_postmeta pm1
     ON p.ID = pm1.post_id
     AND pm1.meta_key = 'author'
    LEFT JOIN wp_postmeta pm2
     ON p.ID = pm2.post_id
     AND pm2.meta_key = 'publisher'
    LEFT JOIN wp_postmeta pm3
     ON p.ID = pm3.post_id
     AND pm3.meta_key = 'book_condition'
    WHERE post_type = 'books' AND post_status = 'publish'
    
  3. for Yoast meta data:

    SELECT 
     p.ID,
     p.post_title,
     p.post_name as url,
     pm1.meta_value as description,
     pm2.meta_value as meta_title
    FROM wp_posts p
    LEFT JOIN wp_postmeta pm1
     ON p.ID = pm1.post_id
     AND pm1.meta_key = '_yoast_wpseo_metadesc'
    LEFT JOIN wp_postmeta pm2
     ON p.ID = pm2.post_id
     AND pm2.meta_key = '_yoast_wpseo_title'
    WHERE post_type = 'page' AND post_status = 'publish'
    /* WHERE post_type = 'post' AND post_status = 'publish' */