5

I came across this problem when I was creating a plugin. I cannot call(access ) wordpress default functions like wp_get_current_user(), $wpdb->get_results(), admin_url() etc. from my plugin files. I can access them from my main file of that plugin in which plugin description is given. But I cannot access them from other plugin files. At that time I heard that if we create a new file functions.php and put these code in that file inside a function I can access all wordpress functions. I did so. But now I cannot access that new function. How can I solve this problem? I think you guys understood what I said. Please help me.

1
  • I guess you are calling your plugin file like this: example.com/wp-content/plugins/my-plugin/plugin-file.php? In that case, indeed, you won't be able to access WordPress functionality because that file does not load the WordPress code. There are different ways to do this, but you should specify what you are trying to do with this file: load it in the admin side or in the front site? Use it to handle form submissions? Display style information? Edit your question to give more information, and leave a comment (If you use @Jan in your comment I get a notification)
    – Jan Fabry
    May 30, 2011 at 10:30

1 Answer 1

8

@Jan : I got the required thing. I just put require_once('../../../wp-load.php'); in my plugin files and now can access all wp functions from there. Any ways thanks for your reply.

1

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.