Skip Navigation

[Résolu] How to List Parents with their Childs

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 6 réponses, has 2 voix.

Last updated by jamesH-3 Il y a 7 années et 7 mois.

Assigned support staff: Caridad.

Auteur
Publications
#215096

Hi

So far I have created two custom post types: Merchants (parent) and Coupons (child). I have also managed to created Content Templates for Merchant posts and added a Coupon View to list only the child coupons for each merchant post.

What I am trying to do now is to list all of the coupons on the home page, something like:

Merchant Name 1 with a link to the Merchant Page (from Merchant Post Type)
Address lines 1 (from Merchant Post Type)
Logo 1 (from Merchant Post Types)
Coupon Title 1 for Merchant1 with a link to the Merchant 1 post (from Coupon Post Type)
Coupon Title 2 for Merchant1 with a link to the Merchant 1 post (from Coupon Post Type)
Coupon Title 2 for Merchant1 with a link to the Merchant 1 post (from Coupon Post Type)

Merchant Name 2 with a link to the Merchant Page (from Merchant Post Type)
Address lines 2 (from Merchant Post Type)
Logo 2 (from Merchant Post Types)
Coupon Title 1 for Merchant2 with a link to the Merchant 2 post (from Coupon Post Type)
Coupon Title 2 for Merchant2 with a link to the Merchant 2 post (from Coupon Post Type)
Coupon Title 2 for Merchant2 with a link to the Merchant 2 post (from Coupon Post Type)

(really trying to do something similar to what is on printmecoupon.com homepage)

I have tried to create a view to do this without success. I can’t work out how to organize the fields in the Layout section.

I would appreciate your help on this?

Thanks

#215159

Dear James,

You need to create 2 Views, a parent view and a child view. The parent view will query the Merchants and show the link with the address. It will also include the shortcode to the child View. The child view will query the coupons and print their links.

There is more information about this over here:
https://toolset.com/documentation/user-guides/querying-and-displaying-child-posts/

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,
Caridad

#215957
Screenshot1.png

Hi Caridad

I first created view for Child Coupons content ([wpv-post-link]) with “Post type Coupon is a child of Merchant post type?? filter.
<wpv-loop>
[wpv-post-link]
</wpv-loop>

I then created a view for Parent Merchants content with no filter and added the Child content view:

<wpv-loop
[wpv-post-link]
[types field="business-address-line" id="$merchant"][/types]
[wpv-view name="coupon-view-for-all-coupons-page"]
</wpv-loop>
<!-- wpv-loop-end -->

However, the outcome somehow is not what I want. I lists the Parent [wpv-post-link] twice: Once with the [types field="business-address-line" id="$merchant"][/types] and once with Child [wpv-view name="coupon-view-for-all-coupons-page"]:

What I am doing wrong? How can I list it once?

Thanks

#216144

Hi
Is there any update on this one?
Thanks

#216334

Dear James,

In the Content selection area, both Views should have different post types selected (Coupons vs Merchants).
Another thing I noticed is wpv-loop badly written, but that might be a type. Can you double check?

<wpv-loop

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,
Caridad

#216363

Hi Caridad

Sorry, it was just a typo error here. It is in fact <wpv-loop>. in the view. Also, both Views have different post types selected:Merchant and Coupon?

Thanks

#216660

Hi Caridad

I have sorted it out!

Thanks anyway