We’d need to see your code loadMunicipios.php to help you troubleshoot.
Sure!
<?php
// 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’ );
?>
UPDATE
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.
UPDATE
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).
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'] ) ) { .... }