WordPress Sage 9 - get dist url?

Viewed 3573

I'm trying to make the move to Sage 9 as a starter template, however when I try use get_template_directory_uri() I get a return from within the /resources directory.

Unfortunately the assets I want are in the dist folder, a sibling of resources (as per Sage 9's documentation)

I'm using @asset which works fine inside a blade, but I cannot access that from within another php file.

In Sage 8 and vanilla WordPress this was always the method I used to access my theme URI.

Is there something I'm doing wrong with this?

Thanks

2 Answers

You can use asset() helper equivalent in other WP PHP files like so:

\App\asset_path('your_folder/file_from_dist.ext');

I think you can use get_theme_file_uri() and that will give you the URL to the theme folder.

In my demo get_template_directory_uri() returns http://sage.test/wp-content/themes/sage-demo while get_template_directory_uri() returns http://sage.test/wp-content/themes/sage-demo/resources.

Related