I am trying to do a more or less routine insert however my code appears to be being called twice. Here is said code:

$market_arr = array(
    'market_name' => $market,
    'future_market_code' => $future_code,
    'fx_market_code' => $fx_code,
    'cfd_market_code' => $cfd_code,
    'etf_market_code' => $etf_code,
    'option_market_code' => $option
);
$wpdb->insert('bu_trade_market', $market_arr);
$market_id = $wpdb->get_var($wpdb->prepare("SELECT market_id FROM bu_trade_market ORDER BY market_id DESC LIMIT 1"));

As it may have a bearing:

  • The code is in a plugin file
  • The code is being called by the page via a function courtesy of exec-php
    • Function literally consists of require('page-in-question.php');
  • I have tried disabling all plugins save my custom plugin and exec-php
  • I have tried adding $wpdb->flush() to the end of the page
  • It inserts once if I put exit; at the base of the file but fails to load the template.

I am EXTREMELY hesitant to make a custom template file for this as it would mean I will need ~100 custom template files.

My question essentially is this: How do I stop it from executing twice.

link|improve this question

Since multiple pages can share the same custom template, I don't see why you would need 100+ template files. – scribu Dec 19 '11 at 6:48
each one is doing different things. ~100 was more an exaggeration. I am essentially using WP as a CMS (at clients request). – Joshua Dec 19 '11 at 23:45
feedback

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
or
required, but never shown

Browse other questions tagged or ask your own question.