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

  1. Cristiano
    Posted 3 years 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();
    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??


  2. Tim Smith
    Posted 3 years 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

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

About this Topic