Skip Navigation

[Resolved] Cannot get CPT child data from a parent’s view

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
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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/Kolkata (GMT+05:30)

This topic contains 0 replies, has 1 voice.

Last updated by tonjt 3 months ago.

Assisted by: Minesh.

Author
Posts
#2791608

Tell us what you are trying to do?

In a direcctory I have a CPT, 'professionista', which is associated to several taxonomies (geographical ones: region etc). This CPT is in a relationship one-to-many with another CPT, 'locations' (cities, where the professional has an office, let's say), which are associated to geographical taxonomies too (url: professionisti/{region}/{province}/{location})

Then I have a view, source 'professionisti', to display all professionals associated to certain taxonomies .

<wpv-loop>
[wpv-post-body view_template="professionisti-list-item"]
<br><hr>
</wpv-loop>

I use a content template built with block editor to display the single listing, where the main content is

<h3>[wpv-post-title]</h3>
<p>Sede/i: [wpv-post-taxonomy type="comune" format="name"]</p>

And I get the name of the professional and the name of the geo taxonomies associated to him. The name of the taxonomies and the name of the CPT locations are the same, so it's not a problem.

Now what I would like to do, instead, is to get a link to the 'location'.
I edited the html in the block editor to create the right url starting from the name of the taxonomy

[wpv-post-taxonomy type="comune" format="name"]

And it worked, but not if the professional has many locations, because wpv-post-taxonomy type="comune" format="name" generates a list of taxonomies, comma separated, but the link would be only one with a non existent last path...

So I tried to create a view, to retrieve locations (and their link) associated to the professional, and then inserted it in the content template, but I cannot get it working ('no items found' for every combination of filter, source and relationship I tried :/). I can get taxonomies, the list of all the locations etc but not the exact locations associated to the professional...

Is there any documentation that you are following?
https://toolset.com/documentation/programmer-reference/views/views-shortcodes/
https://toolset.com/documentation/programmer-reference/views/views-shortcodes/item-attribute/

What is the link to your site?

hidden link

#2791610

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Can you please share problem URL and what URL you want to construct based on what content and send me access details and what is your expected results.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#2791633

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Your structure was bit complex to understand but I think I got it right, please let me know if I'm wrong.

Can you please check now: hidden link

I've adjusted the Query Filters as given under to the view:
=> hidden link

Taxonomy filter
Select posts with taxonomy:
Regioni the same as the current post in the loop
AND
Province the same as the current post in the loop
AND
Comuni the same as the current post in the loop

And adjusted the "Loop Editor" code as given under:

<wpv-loop>
          <li>
         <a href="[wpv-bloginfo show='url']/[wpv-post-type]/[wpv-post-taxonomy type='regione' format='slug']/[wpv-post-taxonomy type='provincia' format='slug']/[wpv-post-taxonomy type='comune' format='slug']">[wpv-post-title]</a>
</li>
		</wpv-loop>

Can you please confirm it works as expected now.

#2791650
Psicologi-Monza-e-provincia-NienteAnsia-01-10-2025_02_25_PM.jpg
Immagine 2025-01-10 143800.jpg

Thank you Minesh, now it works as expected, thank you very much.
I know, it's complicated and heavy, I'm trying to fix it one piece at a time but I'm not a developer...

I've noticed that there's another problem, with the geo filtering...
In theory on /lombardia/monza-e-brianza/ only the locations with the Monza e Brianza province taxonomy should be shown, but instead (and I'm seeing it also on the live site) there are also locations in other regions and provinces.
Which one should be the right filter to apply in this case?

#2791978

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

As per our support policy - we entertain only one question per ticket. This will help other users searching on the forum as well as help us to write correct problem resolution summery.

May I kindly ask you to open a new ticket with every new question you may have. This will also help other users searching on the forum.

#2792126

yes sorry, I was just saying, it's not a problem I would open a ticket for.
Thank you very much Minesh