Posts 2 Posts
[resolved] p2p_list_posts adds extraneous list items in 1.4.2 (4 posts)

  1. leggo-my-eggo
    Posted 3 years ago #

    All of my calls to p2p_list_posts have broken since upgrading to 1.4.2 (and WordPress to 3.4.2, not sure which caused it).

    I'm now getting a list with the actual connection in the last position, and about 45 li's before it containing either and empty anchor tag, or, more often, a link to the current post.

    If I replace p2p_list_posts with a loop, it works fine.


  2. scribu
    Plugin Author

    Posted 3 years ago #

    Code, please!

  3. leggo-my-eggo
    Posted 3 years ago #

    Sorry, of course.

    This used to work, but now causes the problem I described:

    $connected = p2p_type( 'performances_to_reviews' )->get_connected( get_queried_object_id() );
    p2p_list_posts( $connected, array(
    'before_list' => '<aside class="related related-reviews"><h3>Related reviews</h3><ul>',
    'after_list'  => '</ul></aside>',
    'before_item' => '<li>',
    'after_item'  => '</li>',
    ) );

    This works:

    $connected = p2p_type( 'performances_to_reviews' )->get_connected( get_queried_object_id() );
    if ( $connected->have_posts() ) : ?>
    <aside class="related related-reviews">
    <h3>Related reviews</h3>
    <?php while ( $connected->have_posts() ) : $connected->the_post(); ?>
    <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
    <?php endwhile; ?>
    <?php wp_reset_postdata();

    Oh, and the definition looks like this:

    p2p_register_connection_type( array(
    'name'			=> 'performances_to_reviews',
    'from'			=> 'performance',
    'to'			=> 'review',
    'cardinality'	=> 'one-to-many'
    ) );
  4. scribu
    Plugin Author

    Posted 3 years ago #

    Seems to work fine in the development version (1.4.3-alpha)

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Posts 2 Posts
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic