Title: [Plugin: Posts 2 Posts] Nested loop probem
Last modified: August 20, 2016

---

# [Plugin: Posts 2 Posts] Nested loop probem

 *  Resolved [paulcham](https://wordpress.org/support/users/paulcham/)
 * (@paulcham)
 * [14 years ago](https://wordpress.org/support/topic/plugin-posts-2-posts-nested-loop-probem/)
 * Hey,
 * I’m trying to create a page that displays a list of posts by name, and then, 
   under each name, a list of connected posts. I can get it to work with the following
   code but I’d like to also display some of the custom fields in the connected 
   posts. Currently, I can only access a list of links using `p2p_list_posts( $post-
   >connected );`.
 * Here’s my code that is working. Within each office, I list the candidates. Each
   candidate post has custom fields I’d like to access and display.
 * _[Code moderated as per the [Forum Rules](http://codex.wordpress.org/Forum_Welcome#Posting_Code).
   The maximum number of lines of code that you can post in these forums is **ten
   lines**. Please use the [pastebin](http://wordpress.pastebin.com/)]_
 * How do I get access to the custom fields inside my candidate records?
 * Thanks,
    Paul
 * [http://wordpress.org/extend/plugins/posts-to-posts/](http://wordpress.org/extend/plugins/posts-to-posts/)

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

 *  Thread Starter [paulcham](https://wordpress.org/support/users/paulcham/)
 * (@paulcham)
 * [14 years ago](https://wordpress.org/support/topic/plugin-posts-2-posts-nested-loop-probem/#post-2766297)
 * Too much code pasted above – here’s the pastebin:
 * [http://pastebin.com/TBYQhfKH](http://pastebin.com/TBYQhfKH)
 *  Plugin Author [scribu](https://wordpress.org/support/users/scribu/)
 * (@scribu)
 * [14 years ago](https://wordpress.org/support/topic/plugin-posts-2-posts-nested-loop-probem/#post-2766305)
 * Easy: stop using p2p_list_posts().
 * I’ve updated the examples on the wiki page:
 * [https://github.com/scribu/wp-posts-to-posts/wiki/Looping-The-Loop](https://github.com/scribu/wp-posts-to-posts/wiki/Looping-The-Loop)
 *  Thread Starter [paulcham](https://wordpress.org/support/users/paulcham/)
 * (@paulcham)
 * [14 years ago](https://wordpress.org/support/topic/plugin-posts-2-posts-nested-loop-probem/#post-2766407)
 * Thank you! I couldn’t figure out how to set up that foreach loop. Much appreciated!
 * -Paul

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

The topic ‘[Plugin: Posts 2 Posts] Nested loop probem’ 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/)

 * 3 replies
 * 2 participants
 * Last reply from: [paulcham](https://wordpress.org/support/users/paulcham/)
 * Last activity: [14 years ago](https://wordpress.org/support/topic/plugin-posts-2-posts-nested-loop-probem/#post-2766407)
 * Status: resolved