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 🙂
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
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!