• Resolved nickcraig

    (@nickcraig)


    I am using a PHP script to automatically generate a post via WordPress that I want to podcast. I have selected the “Auto Add Media” inside of powerpress, this function doesn’t appear to work until I open the page via the WordPress dashboard and click “Update” on the post.

    The “Auto Add Media” function doesn’t work when a post is created via PHP, any chance of getting that in the next version?

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Support Shawn

    (@shawnogordo)

    I have forwarded your request to the Blubrry support team.

    Plugin Author Angelo Mandato

    (@amandato)

    Hello @nickcraig,

    Your php script that automatically generates posts, are you using the WP functions to create a post or are you adding the records to the database directly?

    Thanks,
    Angelo

    Thread Starter nickcraig

    (@nickcraig)

    Doing it via WP functions like “wp_insert_post($new_post)”. Would be awesome to have this feature for completely automated podcasting.

    -Nick

    Plugin Author Angelo Mandato

    (@amandato)

    Hello Nick,

    I have been doing research on this. The wp_insert_post() function does not call the appropriate hooks. The good news is you’re 95% there. The wp_insert_post function returns the post_id. If you also know the media URL, you can add the record for the “enclosure” (this is what PowerPress uses for the podcast information in the database) a few lines further. The enclosure value is a WordPress field for the enclosure that has 3 lines of information, the media URL, file size in bytes and the content type in that order.

    $post_id = wp_insert_post($data);

    if( $post_id > 0 ) {

    $enclosure_value = ”;
    $enclosure_value = $media_url;
    $enclosure_value .= “\n”;
    $enclosure_value .= filesize($media_url);
    $enclosure_value .= “\n”;
    $enclosure_value .= ‘audio/mpeg’;

    update_post_meta( $post_id, ‘enclosure’, $enclosure_value );
    }

    I got this code from the PowerPress Posts from MySQL plugin: https://www.ads-software.com/plugins/powerpress-posts-from-mysql/ Look at line 153 to see example of doing wp_insert_post and 193 for the meta data enclosure in file includes/class.podcast.php link: https://plugins.svn.www.ads-software.com/powerpress-posts-from-mysql/trunk/includes/class.podcast.php

    Thanks,
    Angelo

    Thread Starter nickcraig

    (@nickcraig)

    Angelo you are the man this works like a charm. Thank you very much!

    Plugin Author Angelo Mandato

    (@amandato)

    Hello Nick,

    Awesome, glad to hear that worked!

    If you end up making your php script into a plugin and post it on www.ads-software.com, please let me know we will link to it in the plugin!

    IF you have a moment free, we would greatly appreciate it if you could leave our plugin a review!

    Thanks,
    Angelo

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Auto Add Media’ is closed to new replies.