Help needed for using Query args at relationships

Support MB Relationships Help needed for using Query args at relationshipsResolved

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #35719
    info@ceescoenen.nl[email protected]
    Participant

    Hi,

    I have a relations from CPT Route to CPT Highlight. I will display from the Highlight only the post from term 'Kunst'. The taxonomy is 'Soort'. What do I add to the key value field on the args?

    #35722
    Long NguyenLong Nguyen
    Moderator

    Hi Cees,

    Here is the example to use the setting query_args when creating a relationship

    MB_Relationships_API::register( [
        'id'   => 'route-to-highlight',
        'from' => [
            'object_type'  => 'post',
            'post_type'    => 'route',        
        ],
        'to'   => [
            'object_type'  => 'post',
            'post_type'    => 'highlight',
            'field' => [
                'query_args' => [
                    'tax_query' => [
                        [
                            'taxonomy' => 'soort', //taxonomy slug
                            'field'    => 'slug',
                            'terms'    => 'kunst', //term slug
                        ],
                    ],
                ]
            ]
        ],
    ] );

    Read more on the documentation https://docs.metabox.io/extensions/mb-relationships/#using-code

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