A
A
aftar2020-11-16 16:06:03
WordPress
aftar, 2020-11-16 16:06:03

How to correctly specify the image path?

Good evening!
Please tell me how to correctly specify the path to the pictures in the code editor.
If you specify such a path in the index, header, footer files, then everything works.
If through the code editor, then no.
It's very inconvenient through the media library ... I

first encountered WP)))

I tried like this

<img src="<?php echo get_stylesheet_directory_uri(); ?>/img/reviews/woman.png" alt="девушка с блокнотом">
<img src="<?php bloginfo('template_directory') ?>/img/reviews/woman.png" alt="девушка с блокнотом">

5fb2792a6cfe0019230786.png

Thank you!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Artem Zolin, 2020-11-16
@aftar

1. You can write the full path or upload to media files
2. You can make a shortcode where you will pass the path and alt, for example [image path="/img/reviews/woman.png" alt="woman with a notepad"], and the output get the html you need
3. You can enable php support in the editor, but this is bad practice and a security hole

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question