• Resolved pzh20

    (@pzh20)


    I’m creating and People table and want to relate records to other records in the same table i.e. Name, DOB …etc and Mother, Father which are relationships to the same People table.

    Is this possible?

    Many thanks
    Pete

Viewing 15 replies - 1 through 15 (of 17 total)
  • Plugin Contributor Jim True

    (@jimtrue)

    Yes, you just point the relationship at the same post type. You do have to set your bidirectional relationship appropriately, however.

    I suggest not using a ‘mother’ ‘father’ and instead use ‘parent’ and ‘offspring’ and make them multiple select.

    ‘parent’ would be relationship field in ‘people’ and would be connected to the bidirectional field through ‘offspring’ or ‘children’.

    If you also wanted to track ‘siblings’ that relationship field would point to itself in the bidirectional connection.

    Thread Starter pzh20

    (@pzh20)

    Thanks for this, I’ll have to have a play around.

    Reagrds
    Pete

    Plugin Contributor Jim True

    (@jimtrue)

    Yep, that’s always the best answer. Try it and see what works ??

    Hello there @jimtrue @pzh20 ,

    I’m very glad to find this thread as I have a very similar problem.

    Let me first say how much Pods open my eyes in terms of WordPress in general and I’m so happy to have found it after looking around on how to create my own post types and fields. I’ve watched loads of videos by now but it’s still a bit of a new thing for me and these bidirectional relationships in my case are really tricking me a bit.

    I’ve got this case:

    I need to show pages for a horse breeder with a horse pedigree in some form (a table representing family tree information per each horse would already be ok, including a photo of the horse). So, pages of individual horses, with parents (preferably mother and father separately) as well as offspring (preferably up to 3 offspring).

    I created a Horses pod and created the fields (among others) mother / father / offspring 1 / offspring 2 / offspring 3. I Then tried to relate them all together so I can click through on every horse page to the individual pages of their parents and or offspring. Those pages should also have the links to their respective offspring and parents as well, and so on.

    Now, in fact this worked.
    Partially.

    Every time when I select a father/mother or a horse to be an offspring from the list, the setting changes again when I fill out other horses. It’s a problem of the relationships I’m pretty sure. But on the front end I cán now finally click through horses as parents and offspring. But the relationships are wrong.

    I really hope in some way or another I can manage to create this structure that I need with Pods.

    Would you be able to do something for me if I give you my login credentials to my site @jimtrue ? I guess you’re too busy for that kinda stuff but still I thought I’d ask.

    Kind regards,

    Twan

    Plugin Contributor Jim True

    (@jimtrue)

    No, we don’t have the support resources to log into your sites. You have attempted to be too granular with the relationships, that’s why that won’t work. If you need to do that level of granularity, you should setup a bridge table that only tracks relationships, is person to person (single select) and relationship type, sibling, offspring or progenitor (or whatever you use for parent). You will not be able to track mother and father separately because to the other side of that relationship, they are just offspring.

    Maybe to clarify a bit more:

    At the Horses Pod, I create these fields and their :

    Nickname
    nickname Plain Text
    birth_date Date
    description Plain Paragraph Text

    mother Relationship ? horses (horse) <small>(Post Type)</small>
    father Relationship? horses (horse) <small>(Post Type)</small>
    child_1 Relationship? horses (horse) <small>(Post Type)</small>
    child_2 Relationship [type: pick]? horses (horse) <small>(Post Type)</small>

    You can see I created a relationship for the family fields related to ‘horses (the same pod). I did not set any bidirectional field as this causes the values not to show at all at the front end.

    Wow that’s an incredibly fast reply. @jimtrue The solution you propose sounds pretty cool, but a bit hard to set up? Would the bridge table that only tracks relationships be another pod? What fields would it have and how would they all relate to the family members?

    Or are you basically telling me to give up?

    I’ve bought 2 pro plugins that would solve the matter but they completely were total trash ( in total spending 80 bucks on them).

    Any tip/advice appreciated ??

    Plugin Contributor Jim True

    (@jimtrue)

    Yes that’s what a bridge table means, another table that only tracks connections between horses. You use that as a multiple select, List View relationship to Horses. That custom post type includes the single select relationship to Horses for tracking all the connections.

    While I appreciate your frustrations with buying pro plugins, Pods is a free plugin, so any of those concerns have nothing to do with us. To your question, Can you do this? https://docs.pods.io/faqs/what-can-you-build-with-pods/

    Plugin Contributor Jim True

    (@jimtrue)

    I never tell anyone to give up, I’m just making suggestions to your data structure. I highly recommend reading that FAQ

    Hi Jim, thank you so much for your suggestions and links. I really enjoy watching your videos in which you show nearly anything is possible with pods. This is the start of a long new study period for me.

    I’ve gone through the FAQ, paid attention while viewing 3 more long videos on Pods (grow, plan, build), but have not found out anything about the ‘bridge table’ you suggest. I’m not even sure if this bridge table is supposed to be a pod or entirely something else. Sorry for my ignorance.

    You mentioned in your first reply:
    “you should setup a bridge table that only tracks relationships, is person to person (single select)”

    And in your second reply:
    “…another table that only tracks connections between horses. You use that as a multiple select”

    All I know is that
    1. I need 1 pod called Horses, and
    2. another Pod (or a table) called Relationships
    3. In the Horse Pod I need to add parents / offspring and (if wanted) siblings.
    4. These fields need to be relational and MultiSelect, but I don’t know to what they should relate and whether or not they should relate bidirectional.
    5. For the Relationships Pod, I don’t know what fields or relationships to add.

    Would it be possible to advise me once more on this?

    I’ve come this far (it actually seems to work but it’s buggy, the relationships keeps changing as I add parents and/or offspring).

    I really hope I can make it work. But I do understand if you can’t get into this so deep and detailed.

    Kind regards,

    Twan

    Plugin Contributor Jim True

    (@jimtrue)

    Unfortunately, the only way for me to test if the structure is going to work for you is to create it and that’s outside our support scope. Our Support is Community provided which means we help each other out. From that FAQ, just build it and see what works for you.

    I’ve already advised you what is not going to work with your current structure. You cannot control the bidirectional connection back into Horses with two separate fields ‘Mother’ and ‘Father’ because they will step all over each other. You need to have those three relationship fields in Horses:

    1) Parents -> Connected to Horses, Multiple Select, List View. Set Bidirectional connection to ‘Offspring’.
    2) Offspring -> Connected to Horses, Multiple Select, List View. Set Bidirectional connection to ‘Parents’.
    3) Siblings -> Connected to Horses, Multiple Select, List View. Set Bidirectional connection to ‘Siblings’.

    Let the ‘Sex’ of the Horse determine whether it’s mother or father. There’s no reason to store those in separate fields. A Horse can only have TWO parents (so set the limit on Parents to 2.

    Plugin Contributor Jim True

    (@jimtrue)

    I also tried to build with the bridge table it didn’t work, but I wouldn’t have found that out without ‘building it’. That’s why you have to just try things. Don’t be afraid to build things. It’s a FREE plugin, it doesn’t cost you anything to try a solution and see if it will work. That’s, honestly, the most frustrating thing to me is that folks are always afraid to just spin up a Local copy of WordPress, install Pods and build something and see what works and what doesn’t.

    It is the ONLY way you will learn to make mistakes and learn from them.

    Hi Jim,

    First of all, thanks I think it worked except for 1 issue now: In the template (for front end view) I can only show 1 Parent field (there is only 1 parent field) and same for the Offspring field, but when there are 2 parents and multiple offspring, it shows the 2 names/links as 1 link as follows:

    “Name_Parent_1_&_Name_Parent_2” shown as 1 link – but directing to only 1 of the parents. o I can’t click on any parent individually. Same goes for offspring. That’s why earlier I worked with offspring 1, 2 and 3, and also mother and father. But like you said (and you were right) it was too granular and didn’t work.

    Any remaining clues on how to tackle this last challenge?

    I totally understand what you mean with testing and experimenting (learning by doing). I have been trying out a lot, honestly. But after 2 weeks of hassle with plugins and now studying pods for about 20 hours straight, I reckoned I needed to reach out to something or someone..!!

    Plugin Contributor Jim True

    (@jimtrue)

    Since that is a multiple select relationship, you would use the [each][/each] template tag as we demonstrate in the Grow Beyond video with the Staff and Services.

    
    [each parent]
    <li><a href="{@permalink,esc_url}">{@post_title}</a></li>
    [/each]
    

    Likewise for Offspring. You will have your lightbulb moment, you may need to watch the Grow Video again, because we show this particular bit quite a few times.

    Plugin Contributor Jim True

    (@jimtrue)

Viewing 15 replies - 1 through 15 (of 17 total)
  • The topic ‘Relationship to same table’ is closed to new replies.