WordPress.org

Ready to get started?Download WordPress

Forums

Posts 2 Posts
Get conections in an archive page (2 posts)

  1. Cristiano
    Member
    Posted 1 year ago #

    Hi friends,
    I need help with this. I miss something and I don´t know what is it.

    This is my connection:

    p2p_register_connection_type( array(
    'name' => 'salas_conciertos',
    'from' => 'sala',
    'to' => 'concerts'
    ) );

    On the "concerts" archive page, I´m trying to get the connected "sala" for each concert. I´m using this code:

    // Find connected pages
    $connected = new WP_Query( array(
    'connected_type' => 'salas_conciertos',
    'connected_items' => $post,
    'nopaging' => true,
    ) );
    
    // Display connected pages
    while ( $connected->have_posts() ) : $connected->the_post();
    the_title();
    endwhile;
    
    wp_reset_postdata(); // set $post back to original post

    I get this error:
    Warning: Could not find direction(s). in /usr/.../wp-content/plugins/posts-to-posts/core/query-post.php on line 16

    What am I doing wrong??
    Thanks!

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

  2. itinerant
    Member
    Posted 1 year ago #

    Try changing $post to get_queried_object just to be sure you have the right type, but the best approach to find connections for each item on an archive page is to use the each_connected approach scribu outlines on https://github.com/scribu/wp-posts-to-posts/wiki/Looping-The-Loop

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic