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
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"
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 ?
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>
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
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