Hi there, I’m setting up a trellis/bedrock/sage project and for sage themes,
/resources is being appended to the theme name when running
wp theme commands. Is this driven by the
style.css file in the resources directory?
When I tried moving that to the top theme directory it did not show up at all in
wp theme list. Currently using wp-cli 1.2.1.
To confirm it wasn’t something specific to my theme, I ran
composer create-project roots/sage testsage dev-master inside
/app/themes (standard bedrock). This theme name is listed as
Other themes do not have this naming structure (migrating from Genesis + child theme) - what causes this and how can it be amended?
Pretty sure this is caused by the technique they use to locate the “theme root” in
/resources. I think the “Theme Name” reported by WP-CLI is just the name of the directory where the theme resides, beneath whatever your theme directory is. If your theme root is in
themes/theme, the name will be theme, but in sage your theme root is
themes/theme/resources, so the name in WP-CLI is
theme/resources. The reason your theme disappeared from WP-CLI when you moves
style.css is that you moved
style.css out of the folder where WordPress looks for it, so that theme was “broken”.
So far as I know there isn’t a way to change this behavior, since it’s just the directory where your stuff is located. It hasn’t caused any problems for me. Is it affecting your workflow somehow?
Thanks for the response! What file defines the directory a theme “resides” in? Is it
index.php? Fairly new to the Wordpress ecosystem so still figuring out all the puzzle pieces.
It’s an inconvenience since I’m supporting both sage and non-sage themes. What I have in place at the moment is adding a
theme_name variable to
wordpress_sites, which I reference in the ansible task to activate a theme. I’ll add a comment to make sure to append
/resources to sage themes. Not a huge deal
I can’t find the canonical page that says this (sorry) but the location of
style.css is the “residence” of your theme. IIRC,
style.css is the only file technically required for a WordPress theme. Most Wordpress documentation says that you have to put
style.css in the very top of your theme directory structure, but it will actually look for it one level deep—a quirk that sage takes advantage of to adjust its directory structure. If you’re interested in how that works, most of the action happens here.
In theory it’s possible to move some files back up into top level of your theme directory and still have sage function correctly (more on that here), which would resolve your issue (theme name would just be
theme), but I’ve never really tried to make that work so I’m not sure how feasible it is.
Interesting, following one of your links it looks like there is active interest in supporting “core” theme files in the root theme directory.
This would be nice, as I’ve currently set two theme variables for some ansible logic,
wp theme activate, along with
"testsage"), to determine which directory to run the yarn commands for sage themes. Would be one less opportunity for a misconfiguration if they were the same