WordPress.org

Plugin Directory

WP file_get_contents()

A WordPress shortcode for PHP's file_get_contents() function.

A WordPress shortcode for PHP's file_get_contents() function.

Examples:

[wp-file-get-contents url="http://example.com/dir/file.html"]

[wp-file-get-contents url="http://example.com/counter/" cache="0"]

[wp-file-get-contents url="file://dir/file.html"]

[wp-file-get-contents file="/dir/file.txt" pre="true" filter="my_custom_filters" cache="3600"]

Note that all local file paths are relative to the wp-contents/ folder. You cannot include files outside of the wp-contents/ folder. As an example, file://dir/file.html and/or /dir/file.html will be interpreted as wordpress/wp-contents/dir/file.html. The .. folder name is also removed from file paths to prevent backing out of the wp-content/ folder.

Shortcode attributes:

  • url = http, https, or file URI.
  • file = path to a local file (relative to the wp-content/ folder).
  • cache = number of seconds to cache the content in the transient cache (defaults to 3600 seconds).
  • pre = wrap the content in <pre></pre> HTML tags.
  • class = wrap the content in the specified div class.
  • filter = apply the specified filter to the content.

Requires: 3.0 or higher
Compatible up to: 4.3
Last Updated: 2015-8-18
Active Installs: 100+

Ratings

0 out of 5 stars

Support

Got something to say? Need help?

Compatibility

+
=
Not enough data

0 people say it works.
0 people say it's broken.

100,1,1
100,1,1
100,1,1
100,1,1
100,1,1
100,1,1