Title: Can&#039;t echo $post
Last modified: August 31, 2016

---

# Can't echo $post

 *  Resolved [Wizardo](https://wordpress.org/support/users/wizardo/)
 * (@wizardo)
 * [10 years ago](https://wordpress.org/support/topic/cant-echo-post/)
 * Hi,
 * I love this plugin first of all, It’s been a long time since I’ve last used it(
   I used it when it was just a git repo). I’ve decided to give the plugin a try
   but I can’t seem to get $post->ID.
 * My Code is:
 *     ```
       <div class="news-grid-item grid">
         <figure class="grid-content effect-layla">
           <div class="img" style="background-image:url(<?php echo wp_get_attachment_url( get_post_thumbnail_id($post->ID) );?>)" alt="thumbnail"></div>
           <figcaption>
             <h2>$post->ID<?php echo wp_trim_words(get_the_title($post->ID), 6); ?></h2>
             <p>Full Article</p>
             <a href="#" data-id="<?php echo $post->ID;?>" data-type="news" class="ajax-get-post" onclick="loadPost(<?php echo $post->ID ?>,'news')"></a>
           </figcaption>
         </figure>
       </div>
       ```
   
 * this line here get’s the attachment url but if I just try to echo the id I can’t
   get it.
    `wp_get_attachment_url( get_post_thumbnail_id($post->ID) );`
 * Any suggestions?
    Cheers, Brook.
 * [https://wordpress.org/plugins/ajax-load-more/](https://wordpress.org/plugins/ajax-load-more/)

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Plugin Author [Darren Cooney](https://wordpress.org/support/users/dcooney/)
 * (@dcooney)
 * [10 years ago](https://wordpress.org/support/topic/cant-echo-post/#post-7390439)
 * Hi Wizardo,
    Oh nice! That was a couple years back now 🙂
 * All you need to do is define global $post; at the top of your repeater template.
 *     ```
       <div class="news-grid-item grid">
         <?php global $post; ?>
         <figure class="grid-content effect-layla">
           <div class="img" style="background-image:url(<?php echo wp_get_attachment_url( get_post_thumbnail_id($post->ID) );?>)" alt="thumbnail"></div>
           <figcaption>
             <h2>$post->ID<?php echo wp_trim_words(get_the_title($post->ID), 6); ?></h2>
             <p>Full Article</p>
             <a href="#" data-id="<?php echo $post->ID;?>" data-type="news" class="ajax-get-post" onclick="loadPost(<?php echo $post->ID ?>,'news')"></a>
           </figcaption>
         </figure>
       </div>
       ```
   
 *  Thread Starter [Wizardo](https://wordpress.org/support/users/wizardo/)
 * (@wizardo)
 * [10 years ago](https://wordpress.org/support/topic/cant-echo-post/#post-7390655)
 * Hi,
    sorry for the late reply, and thank you for the quick reply. This solution
   worked!
 * Thanks for your help,
    Cheers

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Can't echo $post’ is closed to new replies.

 * ![](https://ps.w.org/ajax-load-more/assets/icon-256x256.png?rev=2944639)
 * [Ajax Load More – Infinite Scroll, Load More, & Lazy Load](https://wordpress.org/plugins/ajax-load-more/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/ajax-load-more/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/ajax-load-more/)
 * [Active Topics](https://wordpress.org/support/plugin/ajax-load-more/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/ajax-load-more/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/ajax-load-more/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [Wizardo](https://wordpress.org/support/users/wizardo/)
 * Last activity: [10 years ago](https://wordpress.org/support/topic/cant-echo-post/#post-7390655)
 * Status: resolved