简体   繁体   中英

Wordpress wp_get_attachment_image() to display static image

I am building my header file and I cant figure out how to use the wp_get_attachment_image() to display my logo. The path to the logo is images/logo.png.

Most examples I found online use this to display images dynamically

You can echo the image via:

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

get_stylesheet_directory_uri() returns the "uri" for your active theme.

Read more about get_stylesheet_directory_uri() in the Codex .

You can't use get_attachment_image() in this case, because the image hasn't been attached to WordPress via the Media Uploader.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM