Relative URLs and hide /wp-content/themes/

in my header and other sections I would like to use

<script src="https://wordpress.stackexchange.com/incs/js/script.js"></script>

While maintaining the default theme folder structure in server as below

/wp-content/themes/theme-name/incs/js/script.js

file need to be accessed via browser/html source if need be so that it hides /wp-content/themes/theme-name

http://website.com/incs/js/script.js

This is also applicable to images I may have under /incs/images/imagname.jpg

I’ve seen solutions where defining the directory located outside of theme folder… but need a solution that does this within.

Is this possible?

Thanks

5 s
5

The easiest way to move your theme folder is only via constant; include the wp-content folder.
You can set a constant for the plugin folder and wp-content folder. Then is your plugins and themes in separete url, also in the include in the source of the frontend.

like this example for my dev installs:

define( 'WP_CONTENT_DIR',  dirname( __FILE__ ) . '/wp-content' );
define( 'WP_CONTENT_URL',  'http://' . $_SERVER['HTTP_HOST'] . '/wp-content' );
// Custom plugin directory
define( 'WP_PLUGIN_DIR',   dirname( __FILE__ ) . '/wp-plugins' );
define( 'WP_PLUGIN_URL',   'http://' . $_SERVER['HTTP_HOST'] . '/wp-plugins' );
// Custom mu plugin directory
define( 'WPMU_PLUGIN_DIR', dirname( __FILE__ ) . '/wpmu-plugins' );
define( 'WPMU_PLUGIN_URL', 'http://' . $_SERVER['HTTP_HOST'] . '/wpmu-plugins' );

Leave a Comment