Skip Navigation

[Resolved] Displaying Parent Post Title [Hierarchical not Post One to Many relationship]

This support ticket is created 5 years, 7 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 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

Author
Posts
#1247387

I'm creating a CPT for companies to be listed.
Some companies are part of parent ones. For example:

- Company 1
- Company 2
-- Company 21
-- Company 22
--- Company 221
- Company 3
etc...

In my company posts, I want to list the child companies and parent company of each company. For example:

Company 1 should not show parent or child
Company 2 should show children Company 21 and Company 22 (I was not able to go one level deeper to Company 221but would be great if I can do that too) and show Company 2 as the parent.
Company 221 should only show Company 22 as the parent.

To achieve the View that shows the children for each post, I created a view that filters with Post Parent and filters by "Parent is the page where this View is shown"

How can I achieve the same to show the parent of each post?

Thanks 🙂

#1247687

Hi there,

Thank you for contacting us and I'll be happy to assist.

To show the information about the parent post, you can use the item attribute with "$parent" value, i.e. item="$parent".
( ref: https://toolset.com/documentation/user-guides/views-shortcodes/item-attribute/ )

For example, to show parent post's title with a link, you can use "wpv-post-link" shortcode as:
( ref: https://toolset.com/documentation/user-guides/views-shortcodes/#vf-153370 )


[wpv-post-link item="$parent"]

For the child posts, your adopted approach of using a view with a parent query filter should work just fine.

I hope this helps and please let me know if you need any further assistance around this.

regards,
Waqar

#1248377

Thank you, Waqar especially for guiding me to the correct (an simpler) approach to my issue.
The solution was simpler than I expected.

Still in the learning curve 🙂

My issue is resolved now. Thank you!