Help adding youtube videos programatically to gallery

  • Participant
    Victor on #19362

    Hi everyone, I’m currently trying to write a batch-import script for youtube videos on a particular gallery using mpp_add_remote_media call, but it’s returning 401 error on execution. Could you guys help me sort this. Here’s the snippet of the function I’m using

        $url = admin_url( 'admin-ajax.php' );  
        // $foo = 'bar';
        $post_data = array(
             'action' => 'mpp_add_remote_media',
             'url' => 'https://www.youtube.com/watch?v=JZQzAWzSsn4',
             'gallery_id' => 4005,
             'context' => 'gallery');
        $result = wp_remote_post( $url, array( 'body' => $post_data ) );
  • Keymaster
    (BuddyDev Team)
    Posts: 23812
    Brajesh Singh on #19364

    Hi Victor,
    I am sorry, There is no function named ‘mpp_add_remote_media’ and that’s why you got error. It will be nice to have a simple function in future though.

    For now, to add remote media, you will need to use mpp_add_media() and pass the embed content and url.

    For example, Please see how we are handling it here


    I will provide a simple wrapper function in future.

    Thank you

You must be logged in to reply to this topic.

This topic is: not resolved