• oldsportbiker47

    (@oldsportbiker47)


    I use XYZ Snippets to create most of my website pages so all of my wordpress development is in PHP. My current problem is not being able to access the audio metadata which is stored in a wp_postmeta record referenced by a wp_post record . I’ve tried using wp_read_audio_meta_data passing the audio file URL, (stored in wp_post as guid), but I get an error. Here`s the code:

    global $wpdb ;
    $mime_type = "audio/mpeg";
    $all_mp3s = $wpdb->get_results ( "SELECT * FROM wp_posts WHERE post_mime_type = '$mime_type' " ) ;
    foreach ( $all_mp3s as $all_mp3 )
    {
    $cnt = $cnt + 1 ;
    $post_id = $all_mp3->ID ;
    $mp3_url = $all_mp3->guid ;
    $mp3_title = $all_mp3->post_title ;
    $audio_meta = wp_read_audio_metadata($mp3_url) ;
    if(!audio_meta)
    {
    echo('Call fails for '.$mp3_url.'
    ');
    }
    }

    I suspect the issue is the value of the $mp3_url field and that I need to adjust it somehow. An example of the stored value is : “https://mywebsite.com/wp-content/uploads/2025/01/Back-In-the-USA.mp3.

    On a related note I tried accessing the wp_postmeta directly but the meta_value in the wp_postmeta record is longtext and the php strpos function won’t help me find the tag I’m looking for.

    Tom

Viewing 1 replies (of 1 total)
  • catacaustic

    (@catacaustic)

    Where is the wp_read_audio_meta_data() function coming from? That’s not a core WP function, and a search for it gives me no results anywhere (apart from this page). If you know what plugin is providing that function it’s best off to ask them.

    As for the meta data itself, there should be no issue with searching the contents using strpos() as it’s plain text – assuming that you’ve called it for a single value, eg: get_post_meta ($post->ID, ‘meta_tag’, true); If you’re doing it any other way you’re probably getting an array back, which is not searchable directly.

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.