LoginSignup
1
1

More than 5 years have passed since last update.

wordpressのpostデータをカスタムポストを含めて、csvに出力する

Posted at

最終的なsqlコマンドはこちら

SELECT p.ID, p.post_name, p.post_title,
custom_post_01.meta_value AS custom_post_01,
custom_post_02.meta_value AS custom_post_02,
custom_post_03.meta_value AS custom_post_03
FROM wp_posts AS p
LEFT JOIN wp_postmeta AS custom_post_01 ON p.ID = custom_post_01.post_id AND 'custom_post_01' = custom_post_01.meta_key
LEFT JOIN wp_postmeta AS custom_post_02 ON p.ID = custom_post_02.post_id AND 'custom_post_02' = custom_post_02.meta_key
LEFT JOIN wp_postmeta AS custom_post_03 ON p.ID = custom_post_03.post_id AND 'custom_post_03' = custom_post_03.meta_key
WHERE id IN (SELECT object_id from wp_term_relationships where term_taxonomy_id=1)
INTO OUTFILE '/tmp/wp_posts.csv'
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n';

この辺を調べて対応できた。
http://qiita.com/yahsan2/items/5e342818075c7d0c34f8
http://qiita.com/yahsan2/items/77bae737934a95582fef
http://qiita.com/yahsan2/items/346c821cdd14cad0a704
http://qiita.com/yahsan2/items/3b06e801c7218ea0eefc

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1