I´m trying add my own css a js code which should have influence on element in visual composer created by me. I don not want write my css to style.css of theme. I would rather add css and js with some code in
function.php
function.php
function theme_styles()
{
wp_enqueue_style( 'reference-style', get_stylesheet_directory_uri() . '/own-vc-elements/references/reference-style.css' );
wp_enqueue_script( 'reference-script', get_template_directory_uri() . '/own-vc-elements/references/reference-script.js', array('jquery'));
}
add_action('wp_enqueue_scripts', 'theme_styles');
If your script depends on jquery use wp_enqueue_script()
third argument as below.
wp_enqueue_script( 'reference-script', get_template_directory_uri() . '/own-vc-elements/references/reference-script.js', array('jquery'));
If is not works again check your script path and check your browser console for 404 error.
In wp_enqueue_style()
function parameter replace get_stylesheets_directory_uri()
with get_stylesheet_directory_uri()
- there is an extra s
character -. Also note that you can use get_template_directory_uri()
instead of get_stylesheet_directory_uri()
.
update
Above code solves the assets load problem.
Another problem in cases like this case is file permissions. Set read permission to files and its parents directory solves the problem.