WordPress.org

Ready to get started?Download WordPress

Forums

Activation code not running for default theme (3 posts)

  1. Josh
    Member
    Posted 11 months ago #

    I am running a network site and have the default theme set in my wp-config file like this:

    define( 'WP_DEFAULT_THEME', 'mythemefolder' );

    I have some code in the functions.php file that sets up a new role for this theme and am running in the after_switch_theme action. My problem is that my code only runs if I activate another theme and then switch back to this one.

    What hook should we use to have code only run once when a theme is first used even when it's set as the default theme? From what I've read, after_setup_theme runs on every page load.

  2. bcworkz
    Member
    Posted 11 months ago #

    Perhaps 'wpmu_new_blog' would meet your needs?

  3. Josh
    Member
    Posted 11 months ago #

    I stumbled on that earlier. I tried it in my theme and it appears that the action doesn't run in the functions.php of the theme. I'm extracting my functionality into a plugin to see if I can use wpmu_new_blog there. If it works, I'll post my findings back here.

Reply

You must log in to post.

About this Topic