Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author scribu

    (@scribu)

    Here’s a new tutorial:

    http://github.com/scribu/wp-posts-to-posts/wiki/Looping-The-Loop

    Just replace:

    p2p_each_connected( 'to', 'pages', array(

    with

    p2p_each_connected( 'any', 'pages', array(

    Nick Davis

    (@esanctuary)

    Hi Scribu

    I’m trying to do something similar to picard102, I actually read your ‘Looping The Loop’ tutorial before stumbling on this thread

    I think I’ve got the second part of the tutorial integrated fine (see code here):

    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, it’s not throwing up any results and I think that is because I am now using the p2p_each_connected correctly, I am putting this at the top of my loop code (I also tried it in functions.php) but I am not sure I am using it correctly. I have tried various combinations.

    In this instance I am looking for connections between a shop custom post type with a offer custom post type. The code is on the shop archive page:

    p2p_each_connected( 'any', 'pages', array(
    	'post_type' => 'offer',
    	'nopaging' => true,
    ) );

    I have also tried with post_type as ‘page’ and ‘shop’ and ‘to’ instead of ‘any’ but am not getting any results.

    I really have found the plugin useful so far, however I don’t have a lot of knowledge in this area so I apologise if I am overlooking something really simple but any help you can give really would be much appreciated (by the way I have got things working successfully in single.php and my other variations thereof)

    Thanks

    Nick

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

The topic ‘Use posts to posts in the loop?’ is closed to new replies.