Is wp_read_audio_metadata() function deprecated?

wp_read_audio_metadata() is not deprecated. It’s located in /wp-admin/includes/media.php, which is not loaded on the front end, hence the error your’re getting.

You are using the function correctly. You can make wp_read_audio_metadata() available by including wp-admin/includes/media.php before calling the function, e.g.:

require_once( ABSPATH . 'wp-admin/includes/media.php' );
$audio_file_path = get_attached_file( 1821 ); // example attachment ID
var_dump( wp_read_audio_metadata( $audio_file_path ) );

Leave a Comment