Building a View with data from Two CPTs

Support MB Views Building a View with data from Two CPTsResolved

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #46623
    Grzegorz MicykGrzegorz Micyk
    Participant

    I have created a CPT "SalesRep", with multiple custom fields, that has relationship with User.
    In User Meta I have a Custom Field SalesRep - it's a dropdown that is being fed by "SalesRep" CPT Title (it’s a Post type Custom field)

    I want to create a snippet that would display Sales Rep that is assigned to the current logged in user along with their (SalesRep') contact details. I have no problem displaying the SalesRep name as it is anyway stored in the UserMeta but I have no idea how to pull in their phone number and email which are Custom field for SalesRep CPTs. How can I apprach this?

    #46625
    Grzegorz MicykGrzegorz Micyk
    Participant

    So it's actually not that difficult seems like a good sleep can solve all the issues. Leaving the solution here in case someone stuck as I did.

    In the view editor the most important thing is to connect user to the sales rep. Since I have sales rep ID in user meta all I had to do is:

    {% set post = mb.get_post( user.select_[your_meta_where_ID_is_stored] ) %}
    {{ post.post_title }}
    {{ post.phone}}
    {{ post.emailsales }}

    As easy as that;)

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