Support » Plugin: Posts 2 Posts » Having trouble with loop and the_title showing up

  • I have a basic loop (a rough example of what I’m doing) of work, and want to show the client(s) the work was done for. Some work has clients connected and some doesn’t. The work that doas have one or more client associated with it echos the clients paragraph, and echos it once for each connect client, so it is recognizing the connections. But it doesn’t echo the title, and I cant’t seem to figure out why.

    $my_query = new WP_Query( array(
    	'post_type' => 'work'
    ) );
    p2p_type( 'work_for_client' )->each_connected( $my_query, array(), 'clients' );
    while ( $my_query->have_posts() ) : $my_query->the_post(); ?>
    	<?php the_title(); ?>
    	// Display connected clients
    	foreach ( $post->clients as $post ) : setup_postdata( $post );
    		echo '<p>clients:</p>';
    		echo the_title();

  • The topic ‘Having trouble with loop and the_title showing up’ is closed to new replies.