Custom Fields
Re-Envisioned
Support MB Relationships Basic post type relationship dont work.

This topic contains 3 replies, has 2 voices, and was last updated by  Anh Tran 9 months, 2 weeks ago.

  • Creator
    Topic
  • #9454
    Resolved
    manGometa
    Participant

    Hi, Im trying MB relationships plugin but after many hours I still cant use it. In WP-admin is everything OK, but when I try to query posts from template its failed. Can you take look at this bug? Its really flustrating and usseless now.

    Init:

    add_action( 'mb_relationships_init', function() {
        MB_Relationships_API::register( array(
            'id'   => 'articlebanner_to_articles',
            'from'   => 'm_articlebanner',
            'to'   => 'blog_article'
        ) );
    } );

    Query function:

    function getPostBanner(){
        $connected = new WP_Query( array(
            'post_type' => 'm_articlebanner',
          'relationship' => array(
              'id' => 'articlebanner_to_articles',
              'to' => 3798,
          ),
          'nopaging' => true
        ) );
    
        return $connected;
    }

    DB records:
    https://user-images.githubusercontent.com/1681339/39624540-05ec4464-4f9a-11e8-86d3-ec61692bd31b.png

    Thanks for help.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Author
    Replies
  • #9464

    Anh Tran
    Keymaster

    Hello, the query to get connected posts seems to be ok. What error did you see? Can you please post the code that you use it and see it failed?

    #9469

    manGometa
    Participant

    I didnt see any error, but WP_Query return no posts. If I remove relationship array from WP_Query everything is ok and query return all posts.

    This is query from database, where are posts with same post_type and published:
    https://monosnap.com/file/oMuq2nznqN9aXdp10biwL6YTzOsLLd

    #9498

    Anh Tran
    Keymaster

    Hello,

    I’ve just did a similar test and it works for me. Do you have any filter/code that change the query? Some kind of hooks to pre_get_posts, query_vars, etc.?

Viewing 3 replies - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.