Welcome to Dagon Design. In addition to free scripts, WordPress plugins, and articles, we offer a variety of services including custom theme design, plugin creation, and PHP scripting. Contact me for more information.

Version 1.0   Updated Sunday, February 22nd, 2009 at 5:17pm

Retrieve Data Plugin for WordPress

This plugin provides a simple way to include the contents of data files into your posts or pages. The data files can be local to your server, or on remote servers (if your PHP configuration allows it). In the options page for the plugin, just define the trigger text and the file the data will be retrieved from. When that trigger text appears in a post or page, the contents of the specified data file will be shown.


  If you have found this page useful, please consider donating. Thanks!


  • Download the above file, rename it from .txt to .php, and upload it to your plugins directory
  • Enable the plugin
  • Configure the plugin under the DDRetrieveData options page


This plugin uses the file_get_contents function in PHP. While this function supports the reading of files on remote servers, the allow_url_fopen option must be enabled in PHP. Additionally, firewall software on the server may block remote access.

Change Log

  • 12-27-08 Version 1.0 – First release.

Usage Notes

From the plugin’s options page (DDRetrieveData), simply enter the trigger text and the path to the data file for each set of data you would like to use. If you need more fields, just click ‘Update Options’ to save your changes, and more fields will appear. There is no limit to how many fields you can have.

If using a local file, the path is relative to the WordPress installation directory. Examples:


If using a remote file, be sure to include the full path. Examples:


The default options show an example of each type. Just clear them out to use your own.

The trigger text can be anything you like. The default options show the trigger text being wrapped inside html comment tags. This is optional, but it prevents the trigger text from being shown if the plugin is disabled (as it will just be treated as a comment).

Note: Make sure you add this to your posts/pages using the html/code editor in WordPress, not the visual editor. In new versions of WordPress, just click the ‘html’ button above the edit box. If you use the visual editor it will not work, as the actual code you entered will be seen on the page, instead of being processed by the script.

Data Output

Currently the output of the data is rather simple. It can be seen in this function:

function ddrd_fetch_data($url) {
	return htmlspecialchars(file_get_contents($url));

As you can see, the htmlspecialchars function is used to force the data to show up exactly like it does in the file. If you would rather have html processed, remove that function. If you want to modify the way that the script retrives data (to use CURL for example), this is the function you need to change. The function is given the $url parameter, and returns the contents of the file.

Possible Future Updates

Currently there is no local caching of remote files. This may be added in the future. Other options may be added as well.