• This is probably a noob questions, but I’m using the Posts 2 Posts plugin. I’m trying to display the connected posts as a comma separated list, instead of an unordered, bulleted list.

    Here is the code I began with:

    <?php
    // Find connected pages
    $connected = new WP_Query( array(
      'connected_type' => 'event_to_team',
      'connected_items' => get_queried_object(),
      'nopaging' => true,
    ) );
    
    // Display connected pages
    if ( $connected->have_posts() ) :
    ?>
    <h3>Featuring:</h3>
    <ul>
    <?php while ( $connected->have_posts() ) : $connected->the_post(); ?>
        <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
    <?php endwhile; ?>
    </ul>
    
    <?php
    // Prevent weirdness
    wp_reset_postdata();
    
    endif;
    ?>

    The above code is copied directly from the Plugin’s documentation.

    I edited it to this:

    <?php
    			// Find connected pages
    			$connected = new WP_Query( array(
      			'connected_type' => 'event_to_team',
      			'connected_items' => get_queried_object(),
      			'nopaging' => true,
    			) );
    
    			// Display connected pages
    			if ( $connected->have_posts() ) :
    			?>
    			<h3>Featuring: <?php while ( $connected->have_posts() ) : $connected->the_post(); ?><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
    
    			<?php endwhile; ?>
    
    			<?php
    			// Prevent weirdness
    			wp_reset_postdata();
    
    			endif;
    			?>

    Now the connected posts aren’t showing up as a list, but there is still a <br> between them. I’m attempting to get them to show up next to each other, separated by commas.

    I think the fix is simple, but I’m fairly new to PHP and can’t get it to behave like I want!

    Any help would be awesome.

    Thanks all!

  • The topic ‘[Plugin: Posts 2 Posts] Displaying connected posts as comma separated list’ is closed to new replies.