V
V
Vladislav Chernushevich2015-10-10 02:24:04
WordPress
Vladislav Chernushevich, 2015-10-10 02:24:04

How to display an image in WordPress?

You need to display the image in the post using wp_get_attachment_image_src

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
WP Panda, 2015-10-10
@Uladzislau

Isn't it that difficult?
Go to Google, type in wp_get_attachment_image_src,
follow the first link to the code,
click on Examples -> Default Usage in the menu,
get

<?php 
$attachment_id = 8; // attachment ID

$image_attributes = wp_get_attachment_image_src( $attachment_id ); // returns an array
if( $image_attributes ) {
?> 
<img src="<?php echo $image_attributes[0]; ?>" width="<?php echo $image_attributes[1]; ?>" height="<?php echo $image_attributes[2]; ?>">
<?php } ?>

searching takes less time than writing a question

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question