Title: [Plugin: Posts 2 Posts] Loop on loop &#8211; taxonomy template
Last modified: August 20, 2016

---

# [Plugin: Posts 2 Posts] Loop on loop – taxonomy template

 *  Resolved [Aurélien Denis](https://wordpress.org/support/users/maigret/)
 * (@maigret)
 * [13 years, 11 months ago](https://wordpress.org/support/topic/plugin-posts-2-posts-loop-on-loop-taxonomy-template/)
 * Hi,
 * I’m looking for a little bit of help… 🙂
 * My objectif is to show connected posts to a custom post filtering on meta query(
   custom field).
 * Here is the initial code : [http://pastebin.com/Thhe6EbR](http://pastebin.com/Thhe6EbR)
 * The problem stars on line 33. Multiple data are displayed. I need to show just
   one data. I already do this on single custom post but the same code do not work
   on a taxonomy page.
 * I’m using this piece of code just after line 30 :
 * `
    $connected = new WP_Query( array( 'connected_type' => 'saisons_to_sejours','
   connected_items' => get_queried_object_id(), 'nopaging' => true, 'meta_query'
   => array( 'relation' => 'AND', array( 'key' => 'date_debut', 'value' => $today,'
   compare' => '<=' ), array( 'key' => 'date_fin', 'compare' => '>=', 'value' =>
   $today,
 *  ),
    )
 *  ) );
 * Not sure I’m clear in my explanations…
 * [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, 11 months ago](https://wordpress.org/support/topic/plugin-posts-2-posts-loop-on-loop-taxonomy-template/#post-2795065)
 * So, you’re saying the WP_Query call works fine on other templates.
 * The issue is that, on category template, `get_queried_object_id()` returns the
   current category, not a post.
 * You just need to replace it with `$post`, like you did in your initial code.
 *  Thread Starter [Aurélien Denis](https://wordpress.org/support/users/maigret/)
 * (@maigret)
 * [13 years, 11 months ago](https://wordpress.org/support/topic/plugin-posts-2-posts-loop-on-loop-taxonomy-template/#post-2795083)
 * You’re the King! Lost one entire day looking for my error. 😀

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

The topic ‘[Plugin: Posts 2 Posts] Loop on loop – taxonomy template’ 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/)

 * 2 replies
 * 2 participants
 * Last reply from: [Aurélien Denis](https://wordpress.org/support/users/maigret/)
 * Last activity: [13 years, 11 months ago](https://wordpress.org/support/topic/plugin-posts-2-posts-loop-on-loop-taxonomy-template/#post-2795083)
 * Status: resolved