Roots Discourse

Set Custom Theme on Install

I’m trying to have Trellis set to my custom wp theme on the initial vagrant up install, but struggling.

I’ve referenced this post in my attempt but I believe I am not specifying the path correctly.

Example in site/config/application.php:

define('CONTENT_DIR', '/app');
define('WP_CONTENT_DIR', $webroot_dir . CONTENT_DIR);
define('WP_CONTENT_URL', WP_HOME . CONTENT_DIR);
#Suggested to add the line below:
define('WP_DEFAULT_THEME', CONTENT_DIR . '/themes');

However, in my Sage 10 site/config/application.php file:

Config::define('CONTENT_DIR', '/app');
Config::define('WP_CONTENT_DIR', $webroot_dir . Config::get('CONTENT_DIR'));
Config::define('WP_CONTENT_URL', Config::get('WP_HOME') . Config::get('CONTENT_DIR'));
#Try 1: Prepend config, reference similar variables
Config::define('WP_DEFAULT_THEME', Config::get('CONTENT_DIR') . '/themes');
#Try 2: Add the specific theme name
Config::define('WP_DEFAULT_THEME', Config::get('CONTENT_DIR') . '/themes/mycustomsite-2021');
#Try 3: Hard code path to vm server
Config::define('WP_DEFAULT_THEME', '/srv/www/mycustomsite-2021/current/web/app/themes/mycustomsite-2021');
#Try 4: Same as try 1 above without prepended Config
define('WP_DEFAULT_THEME', Config::get('CONTENT_DIR') . '/themes');
#Try 5: Same as try 2 above without prepended Config
define('WP_DEFAULT_THEME', Config::get('CONTENT_DIR') . '/themes/mycustomsite-2021');
#Try 6: Same as try 3 above without prepended Config
define('WP_DEFAULT_THEME', '/srv/www/mycustomsite-2021/current/web/app/themes/mycustomsite-2021');

In many of these tries, it appears as if it is setting a new theme directory afterall, but thinking it’s in a different path.

Am I specifying the theme in the right file? What about those paths woes?

Thanks!
Jess

Judging from the screenshot WordPress can see the proper sage-based theme, can you manually activate it? What path does the main stylesheet of that theme have (check Web Developer Tools Sources tab or the HTML source to find out).

Yes, I can manually activate the sage theme.

site/web/app/themes/mycustomsite-2021/style.css is the path for the theme style sheet

Try to use the theme slug instead its path for WP_DEFAULT_THEME (https://wpseek.com/constant/wp_default_theme/#source).

1 Like

Thanks @strarsis, that did it.
For posterity:

site/config/application.php

/**
 * Custom Content Directory
 */
Config::define('CONTENT_DIR', '/app');
Config::define('WP_CONTENT_DIR', $webroot_dir . Config::get('CONTENT_DIR'));
Config::define('WP_CONTENT_URL', Config::get('WP_HOME') . Config::get('CONTENT_DIR'));
Config::define('WP_DEFAULT_THEME', 'mycustomsite-2021');