Skip Navigation

[Resolved] Unable to display parent fields on child page

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

Problem: It is possible to output fields from a parent post on the child post page in the content area, but used on other parts of the same page they are not output.

Solution: Outside the content area the context of what is the current post is lost and so the relevant parent cannot be determined from the id="$post-slug" attribute.

The solution is to move the shortcodes which output fields of the parent into a new content template (unassigned) and to insert this content template into the child page using wpv-post-body and the id attribute to specify the child post id to re-establish what the "current" post is.

Relevant Documentation: https://toolset.com/documentation/user-guides/displaying-fields-of-parent-pages/

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.

Tagged: 

This topic contains 2 replies, has 2 voices.

Last updated by MrHinsh 4 years, 5 months ago.

Assigned support staff: Nigel.

Author
Posts
#526940

I am trying to get data from a Parent page to be displayed on a child page, but outside of the standard content. I use Pagelines and want to have some of the data from the parent displayed. However the data is always empty. If I add the same fields to the "content" then the data is visible. however when the field is added to the page (in a Section).

I visited this URL: https://toolset.com/documentation/user-guides/displaying-fields-of-parent-pages/ to get guidance and it implies that I can use the fields in this way. I do however understand that outside of the "content" area may be a new thing.

#526972

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

Hi Martin

You can use the id attribute to tell the Types and Views shortcodes to get content from a particular post (with that id) rather than from the current post, or to get the content from a post related to the current post, as described in the link you shared.

I don't know what page you are working on, but the problem with the second route you are aiming for is that, outside the content area, you have lost the context of what the "current" post is.

You can use the id attribute to set the post context (if you know the id), but then you can't re-use the id attribute to specify what parent post you want to connect to.

There is a workaround for this.

You can make a new Content Template (which you don't assign to any post type) where you insert your Types or Views shortcodes with the id="$parent-slug" attribute to output content from the parent.

Then, back on your page, instead of directly inserting the Types or Views shortcodes, you insert the content template using [wpv-post-body id="99"], where you specify the id of the current post manually, assuming you know what that is.

Let me know if that makes sense and if you are able to implement it.

#526990

Thanks, I am busy creating Content Templates to handle this. I was hoping that I would not need the overhead... but I guess I do 🙂

Thanks for the conformation.