Skip Navigation

[Fermé] Problems with listing parent fields in child content template-2

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.

This topic contains 5 réponses, has 2 voix.

Last updated by Paweł Pela Il y a 7 années et 4 mois.

Assigned support staff: Paweł Pela.

Auteur
Publications
#231945
screenshot.png

Hi Pawel

This is to follow on from my previous thread: https://toolset.com/forums/topic/problems-with-listing-parent-fields-in-child-content-template/

Thanks for your quick response; however, after overwriting frontend.php, unfortunately nothing has changed.

I am happy to provide you with my login credentials if you like.

Thanks

#231953

Dear James,

OK, it seems like it is something else then.

Please provide the access details. I have enabled the private details box.

Thank you!

Regards,
Paweł

#231956

Thanks

#231981

Dear James,

There is no native way to query the parents with a View. You can instead get the parent's fields by creating a Content Template for the custom post type and doing almost exactly what you did in your view (using id="$merchant").

Please let me know if you are satisfied with my answer and if I can help you with any other questions you might have.

Regards,
Paweł

#232202

Hi Pawel

Thank you for your email; however, to be perfectly honest, I find your response less than satisfactory.

I am aware that there is no native way to query the parent fields in child content template. I have created a view for the parent fields that I need and put this view in the child content template, based on an advice given in one of the support threads.

I have given you my access details, have you looked at how I set up my content template and views? Do you think I set them up incorrectly? Why does it display the fields a number of times? Why does it ignore some of the fields but show some? Do you suggest me different solutions because you are not sure what the problem is or have you looked into it first?

Is the method that I am currently using as recommended by one of your representatives in one of the support thread wrong?

Also, I do not understand what exactly you are suggesting me to do? I have already created a content template for parent post type and it is working fine. What I am trying to do here is to include parent fields in the child content template? If you can you explain your solution in a step by step format, I would appreciate it?

Thanks

#232216

Dear James,

What you did wrong was using a View instead of Content Template. A View queries all CPTs (sometimes filtered by additional rules), but it can't be used to display parents of the current post. That's why it displayed three entries. As for the other errors, we can diagnose those once you fix your code.

In short: you should have used a Content Template to display Merchant details, not a View.

Here's a short instruction step by step how to fix this:

1. In the Content Template for Coupons remove this shortcode: [wpv-view name="Merchant Details for Single Page Coupon Template"] and in it's place insert a new Content Template (you can also put the code directly here, but your CT is already complicated, so it's better to split it into parts).

2. Add fields etc. normally, using [types field="" id="$merchant"][/types] You can mostly copy-paste this from your old View.

3. In wpv-if, if you need to check for parent (Merchant) fields, you have to use custom functions and evaluate. You can't do this: [wpv-if fieldname="wpcf-some-merchant-field"] because wpv-if cares only about the fields of your current Coupon.

Once you get that working, please update me on how it went. If you find that some fields are still missing, I'll be happy to help you diagnose this further.

Regards,
Paweł

Le sujet ‘[Fermé] Problems with listing parent fields in child content template-2’ est fermé à de nouvelles réponses.