WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. leggo-my-eggo
    Member
    Posted 1 year 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.

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

  2. scribu
    Member
    Plugin Author

    Posted 1 year ago #

    Code, please!

  3. leggo-my-eggo
    Member
    Posted 1 year 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>
    <ul>
    <?php while ( $connected->have_posts() ) : $connected->the_post(); ?>
    <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
    <?php endwhile; ?>
    </ul>
    </aside>
    <?php wp_reset_postdata();
    endif;

    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
    Member
    Plugin Author

    Posted 1 year 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

About this Topic