0

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.

  • 1
    What is 'custom export field'? – Max Yudin Mar 6 '19 at 10:06
0

I think your syntax is wrong. It should be [get_workhours({ID})]. Also press "Save Functions" button before previewing.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.