Custom Fields
Re-Envisioned
Support MB Relationships when Reciprocal relationship checked cant change connection

  • Creator
    Topic
  • #27988
    Resolved felixwa@gmail.com
    Participant

    Hi, I"m trying to make relationship between CPT Work and CPT Press,
    I want to be able to change the connection on both cpt pages and display the results on both single pages.

    If i uncheck "Reciprocal relationship" i see and can change the connection and it's updates on both posts, but when i display in single.php i can see the selection only on single Work.
    on single press i don't see the results. the code i"m using is bellow.

    If i check the Reciprocal relationship, then i see the results on both single pages BUT i don't get the option to change the connection on CPT press - the connection area field appear only on work page.

    I"m using

    $connected = new WP_Query( [
            'relationship' => [
                'id'   => 'art-work-2-press',
                'from' => get_the_ID(), // You can pass object ID or full object
            ],
            'nopaging'     => true,
        ] );
        while ( $connected->have_posts() ) : $connected->the_post();
            ?>
            <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
            <?php
        endwhile;
        wp_reset_postdata();

    I"m missing something?
    How can i make changes and display on both pages?

    Thank you
    Felix

Viewing 2 replies - 1 through 2 (of 2 total)
  • Author
    Replies
  • #28002
    Long Nguyen
    Moderator

    Hi Felix,

    You can remove "Reciprocal relationship" and use the query on two single templates.

    • In the single Work, use this code
    $connected = new WP_Query( [
        'relationship' => [
            'id'   => 'art-work-2-press',
            'from' => get_the_ID(), // You can pass object ID or full object
        ],
        'nopaging'     => true,
    ] );
    • In the single Press, use this code
    $connected = new WP_Query( [
        'relationship' => [
            'id'   => 'art-work-2-press',
            'to' => get_the_ID(), // here
        ],
        'nopaging'     => true,
    ] );

    then copy the loop from one template to the other.

    #28011
    felixwa@gmail.com
    Participant

    Hi Long
    I understand now.
    Thank you

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.