Reputation: 4301
You'd think there would be a sure answer for this somewhere but I've yet to find one. The problem seems to lie within the function switch_theme()
.
I have some code that is supposed to run when the theme is switched to my theme. However, using the code
add_action('switch_theme', 'activationSetup', 10, 1);
only triggers when the theme is switched AWAY from my theme. I'm guessing that this is due to the theme's functions.php file being triggered only when my theme is active.
I am aware of using wp_head
to trigger the function instead, but it seems very unnecessary given that the function only needs to run once ever. It also looks like it only triggers once the theme has been viewed at least once; which would confuse a lot of users installing this theme.
So, my question is: Has anyone found a way around this? A way to trigger the action at the time of initial theme activation?
Thanks!
Upvotes: 0
Views: 312
Reputation: 10607
I did have this problem a while back ago and did not satisfactorily solve it. But here's someone who I think did:
http://www.krishnakantsharma.com/2011/01/activationdeactivation-hook-for-wordpress-theme/
Upvotes: 1