Site icon Hip-Hop Website Design and Development

Img src path from wp-admin

Hi guys I have a quick question:

My path which I used for images in the php-files locally was something like this:

src="<?php echo THEME_IMG_PATH; ?>/icons/cv_icon.png"

But from the wp-admin this doesnt work and I do have to for example:

src="wp-content/themes/mytheme/images/icons/about_icon.png"

First, why is that? Because i defined the THEME_IMG_PATH in function.php? But then why dont for example

<?php echo get_template_directory_uri(); ?>/images/image.jpg

or

<?php echo get_stylesheet_directory_uri(); ?>/images/image.jpg

work? And, is the wp-content/… way the right way to do it, or should you do it in another way . in a way of good practice? It works but maybe its “wrong” to hardcode it like that.

This img shows that witt using php the php is not treated as code but the src url and another link/imageone showing as it should with a relative path.

Thanks

Solution: look further down on example for shortcoding, editing your functions and then calling this shortcode from wp-admin.