How do I get data from my database into my Custom Export Field
I am trying to get data from my database to export to a XML or CSV File by using a custom query. This is my function with the query :
?php
function get_workhours($ID){
$sql = $wpdb-prepare("SELECT worked_hours FROM db_info WHERE job_id = $ID");
$data = $wpdb-query($sql);
if(empty($data)){
return "0";
}else{
return $data;
} ?
And in my custom export field i have this :
[get_workhours{ID}]
And when I try to preview this it gives me the error :
An unknown error occured.
Suggestions for a better idea for this problem are very welcome aswell.
Thanks in advance,
EDIT : I am using the WP All Export Pro Plugin. When adding a field to export I choose the option : Custom export field.