wp_enqueue_style
and wp_enqueue_script
generate relative path instead of absolute?
]]>
There are two main WP functions to use to find the relative paths within a theme:
get_template_directory()
get_template_directory_uri()
]]>wp_enqueue_style
and wp_enqueue_script
generate <style> and <script> tags with relative urls instead of absolute? When I pass relative url to wp_enqueue_style/script it comes out absolute. For example:
wp_enqueue_style( 'my-theme-style', get_theme_file_uri('/assets/css/theme.css'), array(), null, 'all' );
generates this tag in the <head>:
<link rel='stylesheet' id='my-theme-style-css' href='https://mysite.test/wp-content/themes/mytheme/assets/css/theme.css' type='text/css' media='all' />
What I’m looking for is to make it generate href
with relative url, like this:
<link rel='stylesheet' id='my-theme-style-css' href='/wp-content/themes/mytheme/assets/css/theme.css' type='text/css' media='all' />