WordPress.org

Ready to get started?Download WordPress

Forums

Posts 2 Posts
[resolved] Warning: Could not find direction(s) (...) Line 16 (3 posts)

  1. seocadiz
    Member
    Posted 1 year ago #

    Hi,
    I installed the development version and still have the same problem described has solved in here:
    http://wordpress.org/support/topic/plugin-posts-2-posts-still-missing-data-after-141?replies=31

    So i post it here again, if someone can help me.

    Here is my code:

    The function:

    function my_connection_types() {
    
    		p2p_register_connection_type( array(
    			'name' => 'pages_to_pages',
    			'from' => 'page',
    			'to' => 'page',
    			'reciprocal' => true,
    			'sortable' => 'any'
    	) );
    }
    add_action( 'p2p_init', 'my_connection_types' );

    Printing connected pages:

    $connected = new WP_Query( array(
      'connected_type' => 'pages_to_pages',
      'connected_items' => get_queried_object(),
      'nopaging' => true,
    ) );
    
    // Display connected pages
    if ( $connected->have_posts() ) :
    ?>
    <h3>Related pages:</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;

    And i still get the error:

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

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

  2. scribu
    Member
    Plugin Author

    Posted 1 year ago #

    All you have to do is add 'connected_direction':

    $connected = new WP_Query( array(
      'connected_type' => 'pages_to_pages',
      'connected_items' => get_queried_object(),
      'connected_direction' => 'from',
      'nopaging' => true,
    ) );

    Besides 'from', you can also try 'to' and 'any'.

  3. seocadiz
    Member
    Posted 1 year ago #

    Solved! Thanks.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.