Skip Navigation

[Resolved] Can't use Parent's fields

This support ticket is created 5 years, 12 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

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/Hong_Kong (GMT+08:00)

This topic contains 5 replies, has 2 voices.

Last updated by Luo Yang 5 years, 12 months ago.

Assisted by: Luo Yang.

Author
Posts
#1153121
Schermata 2018-11-26 alle 14.20.35.png

Hi,
i would like to show from a post related to a current post the custom fields.

But it can't allow me to choose the relationship

#1153560

Hello,

I assume we are talking about the many-to-many relationship "Eventi capodanno locali".

Since it is many-to-many relationship, there might be multiple connected posts, so you can not use that option directly, as you can see in your screenshot, many-to-many relationship option is disabled, you can one-to-many relationship options, since there is only one parent "locali" post.

In your case, you will need to create a post view, filter by the relationship "Eventi capodanno locali", see our document:
https://toolset.com/documentation/post-relationships/how-to-display-related-posts-with-toolset/#displaying-many-related-items
section "Displaying many related items"

#1153572

Hi Luo,
thank you.

I need to create an output like this for my site:

<div class="microformat">
<script type="application/ld+json">
{
"@context": "hidden link",
"@type": "Event",
"name": "[wpv-post-title]",
"startDate" : "[types field="dataevento" style="text" format="c"][/types]",
"url" : "[wpv-post-url]",
"location" : {
"@type" : "Place",
"sameAs" : "[wpv-post-url id="$locali"]",
"name" : "[wpv-post-title id="$locali"]",
"address" : "[types field='indirizzo-locale' id='$locali'][/types]"
}
}
</script>
</div>

How can i do it with the views formula ?

#1153633

According to the example output you provided above, it seems to support only one post,

You can create a post view, for example "my-view",
1) query the posts of related post type,
2) filter by the the specific relationship,
3) in section "Limit and Offset", display only one item,
4) in section "Loop Editor", display the data according to your example codes, like this:

[wpv-layout-start]
	[wpv-items-found]
	<!-- wpv-loop-start -->
		<wpv-loop>
{
"@context": "<em><u>hidden link</u></em>",
"@type": "Event",
"name": "[wpv-post-title]",
"startDate" : "[types field="dataevento" style="text" format="c"][/types]",
"url" : "[wpv-post-url]",
"location" : {
"@type" : "Place",
"sameAs" : "[wpv-post-url id="$locali"]",
"name" : "[wpv-post-title id="$locali"]",
"address" : "[types field='indirizzo-locale' id='$locali'][/types]"
}
		</wpv-loop>
	<!-- wpv-loop-end -->
	[/wpv-items-found]
	[wpv-no-items-found]
		<strong>[wpml-string context="wpv-views"]No items found[/wpml-string]</strong>
	[/wpv-no-items-found]
[wpv-layout-end]

4) Enable the option "Disable the wrapping DIV around the View",
this step is required in your case, it will output the result in raw mode.

Then you can display the view's result, like this:

<div class="microformat">
<script type="application/ld+json">
[wpv-view name="my-view"]
</script>
</div>
#1153890

Sorry but it still does'nt work I can't show the parent post.
If i try to select it it show the same issue

#1154365

It is only an example, and in your case, it is many-to-many relationship, so it is not parent/child relationship, if you need more assistance for it, please provide a test site with the problem, also point out the problem page URL and view URL, I can setup a demo for you