Custom theme folder

Is anyone aware of an equivalent to WP_PLUGIN_DIR and WP_PLUGIN_URL for themes that I can define in wp-config.php, or am I stuck creating a mu-plugin and registering a new theme dir?

Related posts

1 comment

  1. The default theme directory is registered like this in wp-settings.php

    // Register the default theme directory root
    register_theme_directory( get_theme_root() );
    

    where

    function get_theme_root( $stylesheet_or_template = false ) {
            global $wp_theme_directories;
    
            if ( $stylesheet_or_template && $theme_root = get_raw_theme_root( $stylesheet_or_template ) ) {
                    // Always prepend WP_CONTENT_DIR unless the root currently registered as a theme directory.
                    // This gives relative theme roots the benefit of the doubt when things go haywire.
                    if ( ! in_array( $theme_root, (array) $wp_theme_directories ) )
                            $theme_root = WP_CONTENT_DIR . $theme_root;
            } else {
                    $theme_root = WP_CONTENT_DIR . '/themes';
            }
    
            return apply_filters( 'theme_root', $theme_root );
    }
    

    The functions get_theme_root() and get_raw_theme_root() seems to be used in other theme related functions.

    I don’t see any theme related pre-defined constants used here so I would think that you are stuck with a plugin 😉

    Maybe playing around with the global $wp_theme_directories might get you somewhere?

Comments are closed.