Roots Discourse

Remove Default WP Themes From Core

Anyone know how to eliminate the automatic download of the default WP themes (Twenty Fifteen, etc)?

Would like to remove them from the admin to clean things up.

4 Likes

Use Bedrock :smile:

You can remove this plugin or just have WP_DEFAULT_THEME defined

4 Likes

I’m a little slow. I’m using Bedrock and already see this snippet, but I have all the default WP themes in my project.

Right, that is pointing WP to the themes in the web/wp/wp-content/themes directory. Removing it will only show themes in web/app/themes.

1 Like

Ok, I’ll just deregister. Thank you.

By deregister, do you mean delete the file web/app/mu-plugins/register-theme-directory.php in your project? Because that’s all you need to do…

2 Likes

yea I just commented it out.

For those like me using Trellis, here is how it seems to me is the best-est way to do it.

Since it’s a configuration you’ll probably want on all your environments, thus edit ./site/config/application.php

Around line 39 you should see:

define('CONTENT_DIR', '/app');
define('WP_CONTENT_DIR', $webroot_dir . CONTENT_DIR);
define('WP_CONTENT_URL', WP_HOME . CONTENT_DIR);

Add a line right underneath:

define('WP_DEFAULT_THEME', CONTENT_DIR . '/themes');

Done.

5 Likes

I had thought WP_DEFAULT_THEME is for defining the default theme - but it seems to be setting the theme directory instead? Is there any documentation for this?

It’s setting the theme directory, not a specific theme. I haven’t noticed that constant mentioned in the docs but a quick check of the code shows this to be the case.

1 Like

Thanks for this. Looking closer though, it looks like this constant is ultimately used for setting the default theme; check it out:

https://core.trac.wordpress.org/browser/tags/5.0.2/src/wp-includes/default-constants.php#L361

The code from Bedrock that you referenced seems to be setting up a directory to contain themes, but only if the default theme constant isn’t set.

this has to be define('WP_DEFAULT_THEME', 'CONTENT_DIR' . '/themes'); (note the single quotes around CONTENT_DIR) - otherwise it will throw a php-error …