Im trying to run a $wpdb->insert ONCE on every page load (for testing purposes). The insert will insert a meta field for a post type. I have tried hooking the insert function into "init", add it to the theme function, hook it to "wp_loaded" and other hooks too. It seems that no matter what I do, the insert runs once before and 1-2 times after the page loads. resulting in 2-3 inserts per page load. I'm going a little crazy here. I have switched to twenty fifteen, and disabled all plugins.

Any ideas whats going on, or how to test it further?

  • Do you have any code you can show? – czerspalace Mar 13 '15 at 18:32
  • 1
    the two most common culprits are browser prefetching and 404s on assets loaded by the page. – Milo Mar 13 '15 at 19:25
  • I am having the same issue. $wpdb-insert is running at least twice on page load. While everything else runs once. – gdaniel Feb 17 '17 at 18:59

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.