0

I'm writing a small function that takes a json file (~1000 objects) and uploads every json object to WordPress posts. I only need to have it run once to migrate data from another system.

I wrote the code in a function in functions.php and added a filter that ran it every time it loaded a page. It almost works but sometimes it runs multiple times.

Are there any way to trigger a hook from a link-click in front-end? That would need for me to get this to work.

  • 1
    Have you considered running this as a WP CLI command instead? Or a REST API endpoint? – Tom J Nowell Oct 21 '19 at 13:08
  • 1
    WOW! WP CLI sound exactly what I need to use! Have never heard of it. – Ola Oct 21 '19 at 13:13

Your Answer

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

Browse other questions tagged or ask your own question.