I am writing a wp plugin. Within it, I have a page located here:


How do I access WP database from this page? Is there any official, proper way that won't break with updates? Or any reliable way at all?

As a second possibility (not preferred) - I was thinking maybe my plugin could create a wordpress page, which then would be somewhere like:


Is this possible? And how would it react to user's changes of permalinks settings?

1 Answer 1


In a nutshell there is no generic reliable way to load WordPress core from arbitrary file. Since core and extensions directories are independent from each other (they are co-located by default, not by necessity) only core configuration "knows" where extensions are, but not other way around.

In private code things like this just get hardcoded. In public code this is pretty much undoable properly.

If it's not critical for you to modify core load process then custom URL is definitely way to go. Implemented via Rewrite API from scratch or as endpoint it will be reasonably reliable.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.