Title: [Plugin: Posts 2 Posts] problem with get_sidebar
Last modified: August 20, 2016

---

# [Plugin: Posts 2 Posts] problem with get_sidebar

 *  Resolved [Francois Lamotte](https://wordpress.org/support/users/francoislamotte/)
 * (@francoislamotte)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/plugin-posts-2-posts-problem-with-get_sidebar/)
 * Hello Scribu,
 * In a template, I’m calling a sidebar template in which a declare the related 
   WP_Query.
 * However this is not the right way to do (or I am missing something) because I’ve
   got notices like :
 * `Notice: Undefined property: WP_Query::$ID`
 * `Notice: Use of undefined constant xxxxx`
 * I’m building my queries like
 * `<?php echo get_post_meta($freemailing->ID, 'wpcf-mailingliste-description', 
   true)?>`
 * or
 *     ```
       <?php $my_product_id = $freemailing->post->wpcf-mailingliste-id; ?>
       <input type=”hidden” name=”productId” value=”<?php $my_product_id ?>”>
       ```
   
 * Any help would be appreciated 🙂
 * [http://wordpress.org/extend/plugins/posts-to-posts/](http://wordpress.org/extend/plugins/posts-to-posts/)

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

 *  Plugin Author [scribu](https://wordpress.org/support/users/scribu/)
 * (@scribu)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/plugin-posts-2-posts-problem-with-get_sidebar/#post-2819628)
 * You didn’t post how you’re getting the `$freemailing` variable.
 *  Thread Starter [Francois Lamotte](https://wordpress.org/support/users/francoislamotte/)
 * (@francoislamotte)
 * [13 years, 10 months ago](https://wordpress.org/support/topic/plugin-posts-2-posts-problem-with-get_sidebar/#post-2819752)
 *     ```
       $freemailing = new WP_Query(array(
         'connected_type' => 'lecons_to_mailinglistes',
         'connected_items' => get_queried_object(),
         'nopaging' => true,
       ));
       ```
   
 * Through the help of a partner, I found a way and It works now with queries like
   this one:
 * `<?php echo get_post_meta($freemailing->post->ID, 'wpcf-mail_teasing_video_titre1',
   true); ?>`

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

The topic ‘[Plugin: Posts 2 Posts] problem with get_sidebar’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/posts-to-posts_7a8e9d.svg)
 * [Posts 2 Posts](https://wordpress.org/plugins/posts-to-posts/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/posts-to-posts/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/posts-to-posts/)
 * [Active Topics](https://wordpress.org/support/plugin/posts-to-posts/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/posts-to-posts/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/posts-to-posts/reviews/)

## Tags

 * [posts-2-posts](https://wordpress.org/support/topic-tag/posts-2-posts/)

 * 2 replies
 * 2 participants
 * Last reply from: [Francois Lamotte](https://wordpress.org/support/users/francoislamotte/)
 * Last activity: [13 years, 10 months ago](https://wordpress.org/support/topic/plugin-posts-2-posts-problem-with-get_sidebar/#post-2819752)
 * Status: resolved