Show always the same image when load pages
-
Hi,
I’m developing my own top-down template, loading all pages in the main page.
My problem is that in the places of images appears only the last to be charged. For example, if I have three pages, each page with a different image, the image that will appear is always the image of the last page.I do not know what the problem is, I’ve seen problems cache, problems with the same variable names and can not solve it.
You can see how can i do that:
<section id="about"> <?php $about = get_page_by_title( 'About' ); $thumb_id = get_post_thumbnail_id($about); $abouturl = wp_get_attachment_thumb_url($thumb_id); ?> <span><?php echo $about->post_title ?></span> <img src="<?php echo $abouturl ?>"/> </section> <section id="news"> <ul> <?php $posts = get_posts(['cat' => get_cat_ID('News'), 'limit' => 3, 'order' => 'DESC']); foreach($posts as $post){ setup_postdata($post); $thumb_id = get_post_thumbnail_id($post, 'news-image'); $url = wp_get_attachment_thumb_url($thumb_id, '300, 300'); ?> <li data-link="<?php the_permalink() ?>"> <img src="<?php echo the_post_thumbnail_url(array(300, 150)); ?>"/> <span> <?php echo the_title(); ?> </span> </li> <?php wp_reset_postdata(); }?> </ul> </section> <section id="contacts"> <?php $contacts = get_page_by_title( 'Contacts' ); $thumb_id = get_post_thumbnail_id($contacts); $contactsurl = wp_get_attachment_thumb_url($thumb_id); ?> <span><?php echo $contacts->post_title ?></span> <img src="<?php echo $contactsurl ?>"/> </section>
How can i solve that?
If you need any more information please ask.Thank’s
- The topic ‘Show always the same image when load pages’ is closed to new replies.