Unable to display relations in a category/taxonomy/archive page loop
-
Hello, as I have mentioned before I love this plugin but I am having a small issue gettng it to work ok within a category/archive/similar loop
I have read the recent tutorial on Scribu’s website (https://github.com/scribu/wp-posts-to-posts/wiki/Looping-The-Loop) but I’m coming unstuck and unable to produce any results.
I have two (custom) post types:
– Shop
– OfferI have successfully related these to each other and am able to display them on the appropriate single-xxx.php pages, however I also wanted to list the appropriate relationships in any appropriate category/taxonomy etc loops.
This is the code I am using for the output:
if ( !empty( $post->connected_pages ) ) { echo '<h5>Connected Pages:</h5>'; echo '<ul>'; foreach ( $post->connected_pages as $post ) { setup_postdata( $post ); echo '<li>'; the_title(); echo '</li>'; } wp_reset_postdata(); echo '</ul>'; }
However I am thinking that is not the issue, it’s the following bit of code I’m not sure about:
p2p_each_connected( 'any', 'pages', array( 'post_type' => 'shop', 'nopaging' => true, ) );
I have tried putting this just above the loop, in the loop and in functions.php and I’m not sure I am doing this correctly at all, because I am getting no results (I have also tried ‘offer’ as the post_type and various other array/parameter combinations).
Nothing breaks on the page, I just don’t get any results either
Would really appreciate any help you can give. I
Thanks
Nick
- The topic ‘Unable to display relations in a category/taxonomy/archive page loop’ is closed to new replies.