Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Add AppPresser Media URL Programatically
<?php
// This example is for the Seriously Simple Podcasting plugin. To use with a different plugin, just replace the post type and meta key
// You would only run this one time, don't leave this code active on your site
$the_query = new WP_Query( array( 'post_type' => 'podcast', 'posts_per_page' => 999 ) );
// The Loop
if ( $the_query->have_posts() ) {
while ( $the_query->have_posts() ) {
$the_query->the_post();
// replace audio_file with the meta key to your existing media url. No markup, should just be a url string.
$url = get_post_meta( $the_query->post->ID, 'audio_file' , 1 );
// save meta field for the app
if( $url ) {
update_post_meta( $the_query->post->ID, 'appp_media_url', $url );
// optionally add an image when the media is played
// $featured_url = wp_get_attachment_url( get_post_thumbnail_id( $the_query->post->ID ) );
// update_post_meta( $the_query->post->ID, 'appp_media_image', $featured_url );
}
}
/* Restore original Post Data */
wp_reset_postdata();
} else {
// no posts found
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.