Custom Fields
Re-Envisioned
Support MB Relationships Relationship WP_Query for Oxygen Builder [Repeater] component

  • Creator
    Topic
  • #30005
    Resolved dp
    Participant

    this can be easily done with mb views but for a reason, need oxygenbuilder repeater component to visually layout each field.

    pls see screenshot -> https://pasteboard.co/KeLh62g.png

    what should be entered in the manual wp_query field?

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

    Hi,

    I'm not sure how the query of Oxygen Builder works but you can check the query param to get the relationship here https://docs.metabox.io/extensions/mb-relationships/#posts

    #30027
    dp
    Participant

    I created a relationship between post to expert (post cpt). Author will create a expert that will link/relate to a post.

    I'm trying to display the linked/related posts on the author archive page.

    Im using the tutorial from metabox doc but getting a Invalid argument supplied for foreach() error.

    sample

    <?php
    
    $auid = get_the_author_meta( 'ID' );
    
    $args = array(
        'author' => '$auid',
        'post_type' => 'post'
        );
    
    $my_query = new WP_Query( $args );
    
    MB_Relationships_API::each_connected( [
        'id'   => 'expert-challenge',
        'to' => $my_query->posts, // Set to $my_query.
    ] );
    
    while ( $my_query->have_posts() ) : $my_query->the_post();
    
        // Display connected pages
        foreach ( $post->connected as $p ) :
          echo $p->post_title;
    
            // More code here.
        endforeach;
    
          echo '<pre>'; var_dump($my_query->posts) ; echo '</pre>';
          
    endwhile;
    //wp_reset_postdata();
    
    
    #30049
    dp
    Participant

    resolved. pls close this

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