[Plugin: Posts 2 Posts] connecting from within a nested foreach loop
-
Hi Scribu,
You always seem to come up with exactly the impossible code I need just as I need it … I’m working with your new posts2posts code over here on a new site and of course really loving it … the taxonomy relationships just weren’t going to work and when you switched this over to have its own table … yay … answer to my prayers … I reworked the whole structure of the site to implement it … hitting a little snag today on the following though so wanted to see if I could get your input:Here’s the scenario:
I have these connections: ( snippet )
`p2p_register_connection_type( ‘product’,’solution’);
p2p_register_connection_type( ‘solution’,’product’);`On my product sidebar I am using the code below to bring in a list of connected solutions separated by the taxonomies they are in:
global $post; $taxonomies = get_object_taxonomies('solution'); foreach( $taxonomies as $taxonomy ) : $taxinfo =get_taxonomy($taxonomy); echo $taxinfo->label; $solution_query = new WP_Query( array( 'post_type' => 'solution', 'taxonomy' => $taxonomy->name, /*'connected_from' => $post->ID, */ ) ); if($solution_query->have_posts()) : echo '<ul>'; while($solution_query->have_posts()):$solution_query->the_post(); $output =''; $output .= '<li><a href="' . get_permalink($post->ID) . '">'; $output .= $post->post_title; $output .= '</a></li>'; echo $output; endwhile; echo '</ul>'; endif; endforeach;
notice that I have commented out the connected_from parameter?
With it commented out, the query returns as it should with the taxonomy headings correct and the for each working as it should … But if I uncomment the connected_from, I lose the foreach capability.
Any ideas why the foreach won’t work with the connected_from in there?
As always your input is highly valued and anticipated …
- The topic ‘[Plugin: Posts 2 Posts] connecting from within a nested foreach loop’ is closed to new replies.