Retriev3r
11/12/2018 - 11:37 AM

WP Shortcode to load remote content

Once done, you can use the shortcode. It’s pretty simple: [show_file file="http://www.test.com/test.html"]

function show_file_func( $atts ) {
  extract( shortcode_atts( array(
    'file' => ''
  ), $atts ) );
 
  if ($file!=''){
    $request = wp_remote_get($file);
    $response = wp_remote_retrieve_body( $request );
    return $response;
  }
}
 
add_shortcode( 'show_file', 'show_file_func' );