Ready to get started?Download WordPress


Posts 2 Posts
get_related duplicate post (2 posts)

  1. Lui Amisola
    Posted 7 months ago #

    I recently been using Posts 2 Posts and I'm so glad that I have discovered this plugin.

    My problem is on get_related, using the actual loop/code on the wiki docs. Some of the post on the loop are duplicates.

    Related Items:
    - Item 1
    - Item 1
    - Item 2
    - Item 3
    - Item 4

    My Code:

    // Find connected pages
    $related = p2p_type( 'consultant_to_service' )->get_related( get_queried_object() );
    // Display connected pages
    if ( $related->have_posts() ) :
    <h3>Related Consultant:</h3>
    <?php while ( $related->have_posts() ) : $related->the_post(); ?>
    <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
    <?php endwhile; ?>
    endif; wp_reset_postdata();

    Please help me. Thank you.


  2. EliasNS
    Posted 6 months ago #

    I think you have the same item connected 2 times, maybe with 2 different services.

    On the other hand, I want yo know if you are able to show more than 4 items. Me not :(


You must log in to post.

About this Plugin

About this Topic