Normally Relative URL’s we use:
src(“/path/image.png”)
This method is not applicable to WordPress.
Use get_template_directory_uri() function in front of relative URL to work as same.
src(“<?php echo get_template_directory_uri() ?>/path/image.png”)
In some themes in wordpress, this may not work. Add the below code for its functioning:
path: wp-includes/theme.php
function get_template_directory_uri() {
$template = str_replace( '%2F', '/', rawurlencode( get_template() ) );
$theme_root_uri = get_theme_root_uri( $template );
$template_dir_uri = "$theme_root_uri/$template";
/**
* Filters the active theme directory URI.
*
* @since 1.5.0
*