Skip Navigation

[Resolved] Displaying custom field from the parent view in the child view

This support ticket is created 4 years, 2 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

Tagged: 

This topic contains 8 replies, has 2 voices.

Last updated by deepS 4 years, 2 months ago.

Assisted by: Shane.

Author
Posts
#1498045

Hi,
I want to know whether it's possible to display the value of a custom field in the parent view to the child view? If yes, how?

#1498339

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Deep,

Thank you for getting in touch.

You can actually do it like this


[types field='my-parent-field-slug' item='@{relationship-slug}.parent'][/types]

Where you will replace "my-parent-field-slug" with the slug of the custom field on the parent and "relationship-slug" with the slug of the post relationship.

This is to be added in your child view.

Thanks,
Shane

#1499099

I think you haven't got my point. I am not talking about post-relationship.
I have created one nested view (child view) named as Exam Detailed Syllabus Child in another view (parent view) named as Exam Detailed Syllabus .
Now I want to use a custom field from the Parent view in the Child view. In that case, I don't know what should be the 'relationship-slug'?
Thanks.

#1501769

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Deep,

If you want to do then there are 2 ways you can get the value in the child view.

The first way is that you can use the parent custom field in the child view and add the relationship slug, like this below.

[types field='my-parent-field-slug' item='@{relationship-slug}.parent'][/types]

To get the relationship slug you will need to Toolset->Relationship, edit your relationship and from there you should see the slug.

The second way is that you can pass the custom field directly into the child view by adding a view parameter.

So on your parent view you will call the child view with a shortcode parameter like this.


[wpv-view name='my-child-view' my_param="[types field='my-parent-field-slug' [/types]"]

Then in the child view you can retrieve this value by using this shortcode.

[wpv-attribute name="my_param"]

Please let me know if this helps.
Thanks,
Shane

#1502865

Sorry, I am a bit confused with your second option.
Should I have to create another view to create a shortcode parameter like this

[wpv-view name='my-child-view' my_param="[types field='my-parent-field-slug' [/types]"]

Or anything else?
If you wish I can share login credentials too. Thanks.

#1503449

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Deep,

Are your views nested? Meaning is your child view inside your parent view ?

If that is the case then method 2 that I shared will work.

If that is not the case then only Method 1 will work. You can actually call the parent custom field directly as long as the relationship slug is provided in the shortcode.

Thanks,
Shane

#1503535

Yah I am using nested views. But how to apply the 2nd method suggested by you? Should I have to create another view for this? Please help.

#1503555

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi deep,

No you won't need to create a second view.

Where you are calling your child view in that parent view just add a parameter to that view call and pass the field into the view like this.

[wpv-view name='my-child-view' my_param="[types field='my-parent-field-slug' [/types]"]

Then retrieve that value in the child view with.
[wpv-attribute name="my_param"]

Hopefully this clears it up for you.

Thanks,
Shane

#1503671

My issue is resolved now. Thank you!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.