I have created a view to list fields from parent and child posts. To do this, I have created a child view and inserted it to the parent view and it is working fine:
Parent field 1
Parent field 2
Child Title 1
Child Title 2
Child Title 3
I created a parametric search for this view by filtering with two other parent fields (let’s call call them parent field 3 and parent field 4). The layout section of the parametric view is something like this:
Unfortunately, when I click on the search button, it does list all possible entries for the number of correct results. For example if there are supposed to be two results that matches the filters, it list all of the possible results twice.
How can I list the correct results only once? I would appreciate your help on this?
I am testing the website in a local environment, so I am unable to provide access to the website. However, I am going to try to give you as much information as I can so you may be able to what I am doing wrong.
I am working on a coupon website for tourists, visiting my home country Turkey. Eventually and hopefully, it will be a website where local small business in Turkey can post their discount coupons and visitors can search and print coupon.
In this instance, I am working with two CPTs: Merchant (parent) and Coupon (Child).
Previously I have created a view just to list all of the coupons available. To do that I have created a view for child CPT and added it to the Merchant view for Merchant CPT. (couponviewforallcouponspage.jpg and merchantviewforallcouponspahewithcouponview.jpg)
This is working fine and I am happy with it (see All Coupons Page.png)
I am trying the create a search page where the results are listed the same way as the All Coupons Page.
I have created parametric search view and used the same view of the All Coupons Page in the HTML Layout section. (Parametricsearchviewforallcoupons.jpg)
However, when I search I lists all results a few times.( parametricsearchpage.jpg)
Thanks for this complete explanation, very useful indeed.
The way you are doing it is wrong. If you call the "Merchant View for All Coupons..." inside of the wpv-loop, it will print all results of this view for each loop item, it doesn't matter search parameters.
First of all you need to know you will list coupons items, so you must use custom fields to this post type in the Filter section.
Then you should create the layout of the view following this one - "merchantviewforallcouponspahewithcouponview", but you can not use the coupon view inside of it. So you can highlight the title of the parent post (Merchant) and should use the ID argument to get the value of the parent post like:
Then to show the value of coupon, you shouldn't use the ID argument:
It will print the link of the coupon, in according the search.