So sorry if this have been answered - but in that case, I surely do not know what to ask.
Anyway, I have built an image slider which changes the image and the description of the image on click of a button. Point be, I dynamically change the source of the img tag using javascript. But the images do not actually appear on the page.
The code holding the images is a simple array and I just iterate over each one Ie: "images/work1.png"
, which works offline, but not via php and or wordpress.
This did not work, so I tried putting it in the php function instead: The javascript looks like:
let imgArray = [
"<?php echo get_theme_file_uri('images/work1.png') ?>",
"<?php echo get_theme_file_uri('images/work2.png') ?>",
... etc
];
So the html looks like :
<img src="<?php echo get_theme_file_uri('images/work1') ?>">
The src tag's content is what changes but it does not take effect.
Any knowledge on why neither of those will actually work? The code works because the associated text for each image still changes via click of the button. Just, the image refuses to display.
functions.php looks like this:
function lcc_style_files() {
wp_enqueue_style('lcc_main_styles', get_stylesheet_uri());
}
function lcc_script_files() {
wp_enqueue_script('main-lcc-js', get_theme_file_uri('/js/scripts-bundled.js'), NULL, '1.0', true);
}
add_action('wp_enqueue_scripts', 'lcc_style_files');
add_action('wp_enqueue_scripts', 'lcc_script_files');
function lcc_features() {
add_theme_support('title-tag');
}
add_action('after_setup_theme', 'lcc_features');
let imgArray = [
is in, is it in a javascript file? Or a PHP file?