• How do I show posts of connected & related? I tried this code but it doesn’t work

    <?php
    // Find connected pages
    $connected = new WP_Query( array(
    ‘connected_type’ => ‘posts_to_pages’,
    ‘connected_items’ => array( ‘get_connected’, ‘get_related’ ) get_queried_object(),
    ‘nopaging’ => true,
    ) );

    // Display connected pages
    if ( $connected->have_posts() ) :
    ?>
    <h3>Related pages:</h3>

    <?php
    // Prevent weirdness
    wp_reset_postdata();

    endif;
    ?>

    Can anyone help me fix the code?

    https://wordpress.org/plugins/posts-to-posts/

Viewing 1 replies (of 1 total)
  • For get related post

    $related = p2p_type( 'posts_to_pages' )->get_related( get_queried_object() );
    if ( $related->have_posts() ) :
    while ( $related->have_posts() ) : $related->the_post();
    the_title();
    endwhile;
    endif;
    ?>

Viewing 1 replies (of 1 total)

The topic ‘Connected & Related’ is closed to new replies.