Wordpress Export Custom Table to CSV

时间:2015-05-12 23:15:53

标签: wordpress export-to-csv

I've got a custom database table that I'm storing information to and I need to export selected rows(id's) to a csv file. Currently I have added a an option for "Export" to my bulk actions and it will export the entire table to a CSV file, but I need to only export entries that have been checked for bulk option. Here is the code I have so far.

The delete feature works when selecting multiple checkboxes.

COLUMNS($R$3:S3)

1 个答案:

答案 0 :(得分:1)

所以,我终于回答了我自己的问题。如果其他人遇到这个问题,这就是答案。

$idList = array();
foreach( $entry_id as $id){
        if ((int)$id > 0) {
        $idList[] = (int)$id;
        }
}//end foreach

$sql = $wpdb->get_results( "SELECT * FROM $bp_table_name WHERE id IN(" . implode(",", $idList) . ")");