Yes, I know that we have get_template_directory_uri(); in referencing to the theme’s directory. It’s working when I put the following code inside index.php or in header.php:

<img src="https://wordpress.stackexchange.com/questions/211710/<?php echo get_template_directory_uri(); ?>/images/sample.png">

But when I’m adding an image inside pages when editing via text, not in visual, it isn’t working. How can I get the images from theme’s images directory into the pages?

Thanks!

5 s
5

<img src="<?php echo get_template_directory_uri().'/images/sample.png'; ?>">

Try this. It should work.
You have to concatenate the results from get_template_directory_uri() and your images directory in echo.

Leave a Reply

Your email address will not be published. Required fields are marked *