The handwritten WP theme, I bring up a record on the page, but I can’t display images, not thumbnails, but images that I upload in recordings. enter image description here

I think in the direction of wp_get_attachment_url() , but I don’t have enough experience, it doesn’t work, I can't find a solution either

 <? $id = $_GET['id']; $product = get_post($id, OBJECT); echo get_the_post_thumbnail($id); echo $product->post_title; echo get_post_meta($id,'price',true); echo wp_get_attachment_url($id); ?> 

Extra code removed

  • It is necessary to display a large photo in the editor or the one on the right, where is the thumbnail? - cooledit
  • photo editor, they are there> 1 - Alexander
  • The rate in the post occurs through the button "Add Media File". From the question it is not clear, with the output of which images is the problem? - cooledit
  • I added a media file, I can’t display it on the page - Alexander
  • As for the image output, which is in the editor (with text), these images are displayed in the template along with all the content through <?php the_content(); ?> <?php the_content(); ?> , but you can read about the miniature here: wp-kama.ru/function/the_post_thumbnail - cooledit 5:58 pm

1 answer 1

Images are in the content of the post. You can get it like this:

 $content = $product->post_content; 

Next, you need to process this html content by extracting tags from it. These are the images. This can be done either by string functions, or by applying the following code:

 get_images($content); function get_images ($content) { // Подключаем DOM parser include_once('simple_html_dom.php'); $html = str_get_html($content); // получаем структуру DOM контента // Находим все изображения в контенте foreach($html->find('img') as $element) { echo $element->outertext; // выводим изображения в виде html кода <img src="..."> } } 

Yes, explanations for this code can be found in this answer .