Servage Magazine

Information about YOUR hosting company – where we give you a clear picture of what we think and do!

The correct way of requesting WP plugin files

Thursday, December 22nd, 2011 by Servage

When developing WordPress plugins, it’s a common pitfall to access plugin files with direct requests. There are many cases in which you need to access a plugin file’s functionality directly, but it shouldn’t be by pointing the URL right at the file. Why not? Because you are circumventing some major WordPress functionality, which you would need to include in an ugly way, which isn’t guaranteed to be compatible with future WordPress versions. You need to use the proper WordPress mechanisms.

Don’t do this:

Access via
Include WordPress in your some file.php with something like require_once('../../../wp-load.php');

Instead you need to let the request go the proper way through WordPress’ request mechanisms.

Do this instead:

Access via
Add a proper hook, so your action will be acknowledged and the myplugin parameter recognized.

If you’re unfamiliar with the meaning of above, check out the following two articles, explaining this issue in more detail:

Don’t include WP-Load please

Direct calls to plugin files

The correct way of requesting WP plugin files, 4.4 out of 5 based on 5 ratings
Categories: Tips & Tricks


You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

No comments yet (leave a comment)

You are welcome to initiate a conversation about this blog entry.

Leave a comment

You must be logged in to post a comment.