WpCode.net

Daily Wordpress Code Snippet

How to Publish a post via remote file

| 0 comments

Pin It

Pasting this code in your function.php file you will be able to publish post starting from a remote file (as you can see in the example the url is http://foo.com/file.txt). Remeber to change the url address before save the snippet, when you click on the save button the post will be grabbed and published. Continue reading

$response = wp_remote_get( 'http://foo.com/file.txt' );
if( is_wp_error( $response ) ) {
   echo 'Something went wrong!';
} else {
   echo 'Response:
';
   print_r( $response );
   echo '
';
}
Source: Wprecipes

Leave a Reply

Required fields are marked *.

*