Skip Navigation

[Resolved] Display custom field of parent and child inline

This thread is resolved. Here is a description of the problem and solution.

Problem: I have a View of child posts placed on a parent post page. I would like to display information about parent and child posts together in the same line of text.

Solution: Move the custom field for the parent post into the View of child posts. This will prevent extra markup from causing the line breaks between field display.

This support ticket is created 7 years, 1 month 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
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 2 replies, has 2 voices.

Last updated by arnoldd 7 years, 1 month ago.

Assisted by: Christian Cox.

Author
Posts
#579584

I have a custom post type "companies". These companies include custom fields including: place-name.

In addition, I have a child post "addresses" for additional locations (one to many).

In the custom post page of a company, I want to show the place name. This can be done simply via a shortcode:
[types field = 'place-name'] [/ types]

But then I will not get the remaining place-names of the child post.

I've made a view with a relationship filter to get the other places.

In the content / page template i add the shortcode and the view next to each other to show all place names.

This works. Only the layout is stacked instead of inline.

I dont think this is the right way to do this. Can you point me in the right direction.

#579636

In the content / page template i add the shortcode and the view next to each other to show all place names.
I think I would move the first shortcode inside the View of child posts, and use the $parent ID attribute to access information from the parent post:

[wpv-layout-start]	
  [types field="place-name" id="$parent"][/types]
  [wpv-items-found]
	<!-- wpv-loop-start -->
	<wpv-loop>
... the rest of your View code ...

Try that and let me know if it works for you.

#579659

It works. Thanks!