Support Forum » User Profile

Forum Replies Created

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • in reply to: Can this be built using Metabox? #31657
    Joseph WongJoseph Wong
    Participant

    Thank you so much for your help! Hope you'll have a great weekend.

    in reply to: Trouble with post to user relationship #30785
    Joseph WongJoseph Wong
    Participant

    Hi Long,

    That did it!

    After I added the post_type argument, I was able to get the related post.

    The code is added on the actual page that displays the data. I'm using Oxygen builder.

    Thanks again and hope you'll have a great rest of the week.

    in reply to: Trouble with post to user relationship #30771
    Joseph WongJoseph Wong
    Participant

    Hi Long,

    Thank you for your help.

    You're correct that the select user is a custom field I added to the user. The other one, select post, is the relationship field

    I used the same code as the one you showed me for the top half of my code but it won't show me the posts connected to the user, for some reason. I found this in the Metabox documentation but I must have messed it up somehow.

    Would you mind please take a look and tell me what I did wrong?

    $connected = new WP_Query( [
        'relationship' => [
            'id'   => 'client_to_assignment',
            'to' => get_current_user_id(), // You can pass object ID or full object
        ],
        'nopaging'     => true,
    ] );
    while ( $connected->have_posts() ) : $connected->the_post();
                echo $connected->post_id;
        ?>
        <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
        <?php
    endwhile;

    Not sure if this helps; here's what's in the relationship table in the database:

    from to  type    order_from  order_to
    900 1   client_to_assignment    1   0

    Thanks for your help!

    in reply to: Trouble with post to user relationship #30737
    Joseph WongJoseph Wong
    Participant

    Morning, Long.

    Thanks so much for getting back to me so fast! I really appreciate you.

    I just replied to your email.

    I created the relationship using the GUI instead of code. I did take a short video just now to show the Relationship page so you can see how I created it. The link is in my email reply.

    Thanks again for your help!

    Joseph

Viewing 4 posts - 1 through 4 (of 4 total)