How would go about if I just want a temporary function? (It’s a converter just for converting Access to WordPress tables). I want to execute several times so therefore I want it automated, but I don’t know how to execute the function after adding the filter in add_action(). After I’m done converting, I will delete the function.
I want to do something like http://url/index.php?convert
function addcoursecategoriesfromaccess() {
//code for converting the table
}
add_action('convert','addcoursecategoriesfromaccess');
//If I type http://url/index.php?convert then I want the addcoursecategoriesfromaccess() to execute
if ($_REQUEST['GET'] == 'convert') {
do_action('convert');
}
I guess I’m missing something very simple, but as a newbie in WP-programming I hope you can help me out 🙂 I’ve the code inside functions.php in the theme.
Use e.g. the init hook instead. For instance;:
(Come up with a better check, though. ?convert could mean anything. And secure it by checking for user permissions, that it hasn’t already run, etc.)
Instead you could hook into init
Then when you want to run it, just go to the URL as you wrote ( {url}/?convert=1 ) and then the addcoursecategoriesfromaccess will run.