2

I'm working on a WordPress project, starting from Mark Jaquith's WordPress-Skeleton repository, using MAMP.

I cloned the repo, updated the WordPress submodule, created a database and updated the local-config.php file.

Everything seems to be fine so far, but when I try to use a different theme (placing it on /content/themes), all the theme's assets get the wrong path (so the site is rendered with no images, no CSS and no JS). For example:

In the source code, a stylesheet link points to:

http://localhost/content/themes/roots/assets/css/main.min.css

when it should be:

http://localhost/lab/Wordpress-Skeleton/content/themes/roots/assets/css/main.min.css

I'm getting the wrong path for all assets in my themes (any theme I place into /content/themes)

For example, in the source code, a stylesheet link points to:

http://localhost/content/themes/roots/assets/css/main.min.css

when it should be:

http://localhost/lab/Wordpress-Skeleton/content/themes/roots/assets/css/main.min.css

While debugging I found out that the global $wp_theme_directories returns an array with two paths, and both are correct:

.../htdocs/lab/WordPress-Skeleton/wp/wp-content/themes .../htdocs/lab/WordPress-Skeleton/content/themes

but, the function get_theme_root_uri() when called from the functions.php of a theme located on the second path from the $wp_theme_directories array, returns:

http://localhost/content/themes

The themes from the folder /wp/wp-content/themes (the default ones that came with the WP submodule update) work fine.

1 Answer 1

3

Turns out the problem was with WP_CONTENT_URL, defined inside wp-config.php:

define( 'WP_CONTENT_URL', 'http://' . $_SERVER['HTTP_HOST'] . '/lab/WordPress-Skeleton/content' );

It seems that $_SERVER['HTTP_HOST'] is returning an incomplete path (only localhost without the folder).

Since I'm using version control and using a local-config.php to define some local dev variables (like database credentials), I also placed this on it:

define( 'WP_CONTENT_URL', 'http://' . $_SERVER['HTTP_HOST'] . '/lab/WordPress-Skeleton/content' );

and on wp-config.php I added this check:

if ( !defined( 'WP_CONTENT_URL' ) )
    define( 'WP_CONTENT_URL', 'http://' . $_SERVER['HTTP_HOST'] . '/content' );
1
  • Can you explain why that made the difference? Other people with the same problem would be helped by a better description of the solution.
    – s_ha_dum
    Commented Nov 4, 2014 at 22:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.