Display image in WordPress theme without media library upload - not showing up

I’m working on my WordPress site and want to include an image directly in my theme files instead of uploading through the media library. I tried using this code:

<img src="<?=get_template_directory_uri(); ?>/assets/img/logo.png" alt="Site Logo" />

The image path seems right when I check the file structure, but nothing appears on the frontend. I double checked that the PNG file exists in the correct folder. Has anyone else run into this issue? I thought this would be straightforward but maybe I’m missing something obvious. Any suggestions on what might be going wrong or a better way to reference theme images directly?

hmm interesting! check the console for errors when you inspect element - sometimes images load fine but css hides them. try pasting the full url directly in your browser: yoursite.com/wp-content/themes/yourtheme/assets/img/logo.png. does it show up? also worth checking file permissions.

Had the same issue when I switched from short tags to standard PHP. Your <?= tags probably aren’t enabled on your server. Replace them with full PHP tags:

<img src="<?php echo get_template_directory_uri(); ?>/assets/img/logo.png" alt="Site Logo" />

Most hosts disable short tags by default for security. I wasted hours checking file permissions and paths before figuring this out. Standard PHP syntax fixed it instantly. Also double-check your theme’s actually active and you’re editing the right template file.