Pull image from post worpress

Asked

Viewed 488 times

0

Hello, I’m developing a blog on my site, and added within the post an image through media insertion, however, I would like to know how I pull this image from the media through the code to insert elsewhere the same image.

Example: inserir a descrição da imagem aqui

I would like to insert above the text creation of sites on big beach. I’ve done a lot of real research, I’m not doing soft body, but I still can’t find anything or I didn’t do the research like it has to be done, I’ll be waiting for you. Thanks in advance

  • Your question is very vague, but supposing you want to do it within the loop, I think the way is to use $media = get_attached_media( 'image' );

  • So, why on my site has the page that lists all posts made and within each post of these have an image inserted through the media.. i want on the page listing all posts not only have the title and the date, have the image containing inside his post.. understood?

  • Post the se loop code. Things will get easier

1 answer

2


For display of images inside the loop wordpress, you can use the function the_post_thumbnail().

If you want to only take the image of a particular post outside the loop, use the function get_attached_media(), where the first parameter is the name of the media, audio, image etc, and the second the ID of the post.

  • Posha, it worked out Rafael. Thank you very much! And if it’s for recents or most visited posts?

  • @carloshsa please mark my answer on the left side of the question as "solved", regarding the most recent and visited posts it would be better to create another question.

  • Okay, thank you!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.