0

I want to add a product programmatically using a wordpress plugin but programmatically as entering it manually is a hassle. I have a little bit of programming experience.

I found this: What is your best practice to execute one-time scripts?

The only issue that I'm having is how do I call functions from a plugin in this script? I guess more specifically, what is the base path of plugin .php files that I would pass in to include() ? An example would be great.

0

I would lean toward the approaches by babixeddu, Amit Sukapure, or tf from the question you referenced. As WordPress loads normally with those solutions you can use Core functions to manipulate data. In your case, you'd need plugin_dir_path()

In my case, I have a very simple plugin that creates an admin page with a single "execute" button on it. I hack in the code, upload the plugin, login, and click. That method prevents accidentally running the code multiple times. I can then remove the plugin.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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