Skip Navigation

[Geschlossen] Question about the correct way to do make post relationship filters

This support ticket is created vor 8 Jahre. There's a good chance that you are reading advice that it now obsolete.

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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9: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/Hong_Kong (GMT+08:00)

This topic contains 5 Antworten, has 2 Stimmen.

Last updated by Luo Yang vor 8 Jahre.

Assisted by: Luo Yang.

Author
Artikel
#385839

This question is two fold.
Part 1)
I am trying to:

Create a view with a parametric search to display the Child posts ( Auction Lots) of a CPT (Sale).

I visited this URL:
hidden link

The search filters are supposed to only show the Auction Lots that belong to the parent sale. This works, however if I hit the reset button, it starts to show other lots form other sales. For example when you hit reset you get two Lot 1's. The first one is supposed to be there, the second one is not. If I refresh the page, everything goes back to Normal.

Part 2 of the question.
In the parametric search I understand that it is necessary to have filters in order to filter the data that is displayed. I have gotten the Post relationship filter working as far as I can tell. I have also gotten the Custom Field filters working and only displaying results for the parent CPT that we are browsing.

Current settings for filters:
hidden link

I need to add in another filter for "Session". Currently only the session that the auction lots in the results belong to displays in the drop down box. This needs to display all sessions so the visitor could jump ahead to the session they are interested in.

When I add in a filter for a Taxonomy (Auction Category) I seem to break the search, I have tried all the options. I would like to be able to allow the visitor to filter the lots displayed by Category.

As we stand, Session is it's own CPT and Category is a Taxonomy of Auction Lot.

I look forward to your advice.

Josh

#386098

Dear josh,

Q1) I assume the problem page is single "Sale" post, which is parent post type of "Auction":
hidden link
Please replace the Post relationship filter in your view with:
Select posts that are children of the Post where this View is shown.
See our document:
https://toolset.com/documentation/user-guides/querying-and-displaying-child-posts/
Screenshot:
hidden link

Q2) How do you setup the post type "Session", is it a parent post type of "Auction", I did see it in your screenshot:
hidden link

Could you describe detail steps to duplicate same problem? thanks

#386213

Hi Luo!

Thank you for your reply.

Unfortunately changing the post relationship filter did not solve my problem with the reset button. I am using the following shortcode for the reset button:
[wpv-filter-reset reset_label="RESET" class="searchbutton" type="input"]
Screenshot of Sale View on first load:
hidden link
Screenshot after reset buttons has been pressed:
hidden link
Lots belonging to a different sale are shown.
Currently I only have two sales loaded.

Regarding part 2 for my question;
The CPT Session is a child of Sale and the parent of Auction Lot
Screenshot of the session dropdown viewing Lots 1-15
hidden link
As you can see only session 1 is visible.
On a page where there are lots from two sessions, two sessions are visible:
hidden link

What I am trying to achieve is to have all Sessions in the drop down box that belong to the Sale in question.
Screenshot of the Query Filter settings:
hidden link

Once I have this working I will need to get the Auction Category which is a Taxonomy of Auction Lot displaying in the drop down.

Thanks Luo, I will keep a look out for your reply.
Regards,
Josh

EDIT:
Code for Filter is:

[wpv-filter-start hide="false"]
[wpv-filter-controls]

<table>
  <tr>
    <td>
      <div class="searchbox">
        <h4>Search by Title:</h4> [wpml-string context="wpv-views"][/wpml-string] [wpv-control field="lot-name" url_param="lot-name" type="textfield"]
      </div>
    </td>
    <td>
      <div class="searchbox">
        [wpml-string context="wpv-views"]<h4>Search by Artist/Author:</h4>[/wpml-string][wpv-control field="artist-author" url_param="artist-author" type="textfield"]
      </div>
    </td>
  </tr>
  <tr>
    <td>
      <div class="searchbox">
        [wpml-string context="wpv-views"]<h4>Select Auction Category:</h4>[/wpml-string] [wpv-control taxonomy="auction-cat" url_param="wpv-auction-cat" type="select"]
      </div>
    </td>
    <td>
      <div class="searchbox">
        [wpv-control-set url_param="wpv-pr-child-of" ancestors="session"]
          [wpml-string context="wpv-views"]<h4>Select Session:</h4>[/wpml-string] [wpv-control-item type="select" ancestor_type="session" ]
        [/wpv-control-set]
        
      </div>
    </td>
  </tr>
  <tr>
    <td>
      <div class="searchbox">
        [wpml-string context="wpv-views"]<h4>Search by Lot Number:</h4>[/wpml-string] [wpv-control field="lot-number" url_param="lot-number" type="textfield"]
      </div>
    </td>
    <td>
        [wpv-filter-submit name="Submit" type="input"]
      	[wpv-filter-reset reset_label="RESET" class="searchbutton" type="input"]
        [wpv-filter-spinner container="div" position="before" spinner="<em><u>hidden link</u></em>"][/wpv-filter-spinner]
    </td>
  </tr>
</table></br>
[/wpv-filter-controls]
[wpv-filter-end]

Loop output is:

[wpv-layout-start]
	[wpv-items-found]
<div>Current Page: [wpv-pagination][wpv-pager-current-page][wpv-pager-prev-page]</div>
<div>[wpml-string context="wpv-views"] Previous [/wpml-string][/wpv-pager-prev-page][wpv-pager-next-page][wpml-string context="wpv-views"] Next [/wpml-string][/wpv-pager-next-page][/wpv-pagination]</div>
</br>
<!-- wpv-loop-start -->
<div>
  <link rel="stylesheet" href="<em><u>hidden link</u></em>">
  <script src="<em><u>hidden link</u></em>"></script>
  <script src="<em><u>hidden link</u></em>"></script>
	<div class="container">
	<wpv-loop>
      	<div class="row">
          <div class="col-md-8">
          <h3>[wpv-post-link]</h3>
          </div>
      	</div>
		<div class="row">
      <div class="col-md-3">
        [types field="image" size="medium" align="none" resize="proportional"][/types]
      </div>
      <div class="col-md-5">
	  		<ul style="list-style-type:none">
              <li><b>Lot:</b> [types field="lot-number"][/types] <b>Session:</b> [types field="session-name" id="$session"][/types]</li>
              <li><b>Category:</b> [wpv-post-taxonomy type="auction-cat" format="name"]</li>
  				[wpv-conditional if="( NOT(empty($(artist-author))) )"]
              <li><b>Artist/Author:</b> [types field="artist-author"][/types]</li>
  				[/wpv-conditional]
              <li><b>Estimate:</b> R[types field="low-estimate"][/types] - R[types field="high-estimate"][/types]</li>
              [wpv-conditional if="( $(wpcf-sold-unsold) eq 'sold' )"]<li> Absentee Bidder Form: <a href="<em><u>hidden link</u></em>" target="_blank">Click here to download</a></li>[/wpv-conditional]
      	</ul>
      </div>
    </div></br>
	</wpv-loop>
</div>
</div>
<div>Current Page: [wpv-pagination][wpv-pager-current-page][wpv-pager-prev-page]</div>
<div>[wpml-string context="wpv-views"] Previous [/wpml-string][/wpv-pager-prev-page][wpv-pager-next-page][wpml-string context="wpv-views"] Next [/wpml-string][/wpv-pager-next-page][/wpv-pagination]</div>
</br>
	<!-- 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]
#387391

Thanks for the details,
Q1) I can not duplicate same problem, see below test site:
hidden link
and
hidden link
user/pass: xgren/11111
When I click the "Reset" button, it still output the child post of current "Sale" posts

using view:
hidden link
filter with:
Select posts that are children of the Post where this View is shown.

And using content template for single "Sale" post:
hidden link

Q2) See below test site:
hidden link
using view:
hidden link
filter with:
Select posts that are children of the Post with ID set by the URL parameter wpv-pr-child-of.
eg. hidden link
in section "Filter", use below codes:

[wpv-filter-controls][wpv-control-set url_param="wpv-pr-child-of" ancestors="sale>session"]
	[wpv-control-item type="select" ancestor_type="sale" default_label=""]
	[wpv-control-item type="select" ancestor_type="session" default_label=""]
[/wpv-control-set][wpv-filter-submit name="Submit" type="input"][wpv-filter-reset reset_label="Reset" type="input"]
[/wpv-filter-controls]

More help:
Parametric search – Letting Visitors Filter Content
https://toolset.com/documentation/user-guides/front-page-filters/

Hope it help

#389240

Hi Luo.

That is strange that you can't replicate the error. I am not sure what the solution may be. Do you have any suggestions?

As far as the problem form Q2 goes, I think I am going to simplify the way I am working things and just add a field on the Auction Lot CPT to add in the session and the Category. This will solve that issue.

#389282

I suggest you duplicate same problem in above test site, if you can not too, please try this:
Deactivate other plugins and switch to wordpress default theme and test again.

Das Thema „[Geschlossen] Question about the correct way to do make post relationship filters“ ist für neue Antworten geschlossen.