I need to reference a image from functions file, and I was figuring out how to do it.
I think you can use get_theme_file_uri()
and that will give you the URL to the theme folder.
I’ve tested with get_theme_file_uri()
but it returns http://sage.test/wp-content/themes/sage-demo
while get_template_directory_uri()
returns http://sage.test/wp-content/themes/sage-demo/resources
.
The problem is when I do a yarn build:production
the image change the name and It doesn’t work.
I’ve tried with @asset but it doesn’t work on functions file. This is what I actually have:
add_filter( 'wp_postratings_site_logo', 'wp_postratings_site_logo' );
function wp_postratings_site_logo( $url ) {
return get_theme_file_uri() . '/dist/images/logo.svg';
}
Any help here?
Thanks in advance