WordPress.org

Ready to get started?Download WordPress

Forums

Posts 2 Posts
Having trouble with loop and the_title showing up (1 post)

  1. hept27
    Member
    Posted 1 year ago #

    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.

    <?php
    $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(); ?>
    
    	<?php
    	// Display connected clients
    
    	foreach ( $post->clients as $post ) : setup_postdata( $post );
    		echo '<p>clients:</p>';
    		echo the_title();
    
    	endforeach;
    
    	wp_reset_postdata();
    
    	?>

    http://wordpress.org/extend/plugins/posts-to-posts/

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic