Support » Plugin: Pods - Custom Content Types and Fields » PodsAPI – php function not found

  • Resolved josesreis


    I’m pretty sure the problem is not with PODS but rather is with my php lack of knowledge, in which case I apologize for posting it here. Nevertheless, I appreciate all the help anyone can give me.

    I trying my own example of to load some data executing the PHP code straight from the web browser. The error I’m getting is “Fatal error: Uncaught Error: Call to undefined function pods_api() in C:\xampp\htdocs\php\loadMunicipios.php:4 Stack trace: #0 {main} thrown in C:\xampp\htdocs\php\loadMunicipios.php on line 4“.

    I already tried to include PodsAPI.php but with now success.


    • This topic was modified 1 year, 4 months ago by josesreis.
Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Jim True


    We’d need to see your code loadMunicipios.php to help you troubleshoot.



    // Get the API
    $api = pods_api( ‘npsau_municipio’ );

    // Setup the data to import
    $data = array(
    0 => array(
    ‘name’ => ‘My first event’,
    ‘start_date’ => ‘2009-10-30 08:24:30’,
    ‘attendees’ => array( ‘Bill Gates’, ‘Steve Jobs’, ‘Mario Andretti’ )
    1 => array(
    ‘name’ => ‘My second event’,
    ‘start_date’ => ‘2012-12-25 06:45:00’,
    ‘attendees’ => array( ‘Al Gore’, ‘Bill Clinton’ )
    2 => array(
    ‘name’ => ‘My third event’,
    ‘start_date’ => ‘2010-01-20 11:59:99’,
    ‘attendees’ => array( ‘Rick Astley’ )

    // Run the import
    $api->import( $data );

    // Get CSV data
    $data = file_get_contents( ‘municipios.csv’ );

    // Run the import and set the format to CSV
    $api->import( $data, false, ‘csv’ );


    Just tried running the same code with plugin “PHP Everywhere” and no error is displayed. The dummy page that I use to run the PHP code executes, but no data is inserted in the database.

    Just sharing other way to bulk upload custom data into custom types without using any code:
    – installed plugin WP All Import;
    – installed plugin CIO Custom Fields Importer (WP All Import free version does not load custom type custom fields data – you need CIO CFI plugin to achieve that).

    Plugin Author Scott Kingsley Clark


    So the function error here about pods_api() not being found is probably because the code is being run either outside of WordPress (calling the PHP file directly) or before Pods and other plugins are included by WordPress. May be best to run this code during the ‘init’ action and only on an intentional request to run the import — look for a $_GET query variable like if ( ! empty( $_GET['run_my_import'] ) ) { .... }

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘PodsAPI – php function not found’ is closed to new replies.