Skip Navigation

[Gelöst] Adding a parametric search to content template to display child posts

Dieser Thread wurde gelöst. Hier ist eine Beschreibung des Problems und der Lösung.

Problem:
Displaying a parametric search that uses a filter by post relationship.

Solution:
1) setup the post type parent/child relationship
2) in the Views filter form, use shortcode [wpv-control]-set to add the dropdown menu of parent posts

Relevant Documentation:
https://toolset.com/documentation/views-shortcodes/#wpv-control-set

This support ticket is created vor 8 Jahre, 1 Monat. 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 joshB-6 vor 8 Jahre, 1 Monat.

Assisted by: Luo Yang.

Author
Artikel
#373069

I am trying to create content template for my site.
The site is an auction site and the CPT's I am currently working on are for the catalogue.

I have made a view that displays the list of all the previous auctions which works great.
hidden link
If you click on the auction you would like to investigate, it would take you to the content template for the CPT called 'Sale'. The sale CPT has a child called 'Session' and a child called 'Auction Lot'

I have been able to successfully create a parametric search for a single sale linked below as a temporary measure to get the data from the most recent sale viewable:
hidden link

What I am struggling to do is to convert the view above into a content template. I notice that when creating a content template you cannot create a parametric search, however it is possible to create a parametric search as a view and insert the short code into the content template. I would love to know your advice on how I should go about tweaking my existing view to only display the data associated with the parent CPT (sale)

The parametric search for current Auction Results looks like this:

I have a feeling, and hope It is something small to specify to only display the content associated

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

<table>
  <tr>
    <td>
      <div class="searchbox">
        <h4>Search by Title:</h4> [wpv-filter-search-box]
      </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]

 

I look forward to your advice.

Regards.
Josh

#373356

Dear josh,

Could you describe the question with more details?
it is possible to create a parametric search as a view and insert the short code into the content template

Are you going to display the filter form only?
If it is, you can try with Views shortcode [wpv-form-view], for example:
[wpv-form-view name='my-view' target_id='xx']
The target_id attribute is the post ID of target page/post

#373686

Hi Louy

Thank you for your reply.

The parametric search above was one that I made to search through the auction lots, however when I upload all the previous auctions data (sales) I need the parametric search to be able to only search through the specific parent sale's auction lots.

The hierarchy goes like this:
CPT Sale (parent)
CPT Auction Lot (child)

The visitor will click on the link previous auctions link. The link below is what it would look like:
hidden link

Then the user would select the sale they wish to browse the results of, e.g. sagewood auction.

The results need to be like this parametric search that I have already made (code above)
hidden link

However if i use the above code for the parametric search, it searches through and shows all the auction lots in the database. I need it to only show the auction lots from the parent CPT (sale).

The shortcode for the parametric search will be placed int he content template.

does that make sense to you?

#373727

Hi Luoy

I just wanted to add to my previous post,

If I were to enter the shortcode for the parametric search into the content template for the CPT "Sale"
I need to specify that it only shows the results for the child CPT's.

If the shortcode is:
[wpv-view name="sale-content-template-view"XXXXX]

I assume I would need to enter something in place of the XXXXX to tell the shortcode to only display child results from the parent?

#373933
57.JPG
56.JPG

Sorry, I am still not clear for the questions, please correct me if there is any missing:
Step 1)
The visitor will click on the link previous auctions link. The link below is what it would look like:
hidden link

I tested above URL in my Chrome browser, but I can not find the "the link previous auctions link", where can I find it? How do you setup it?
Is it the the "Previous" and "Next" links below the parameter search form? see screenshot 56.JPG
If it is, how do you setup the view with pagination? is it query the "Auction" posts? how do you setup the filters in it

step 2)Then the user would select the sale they wish to browse the results of, e.g. sagewood auction.
How do you want the user to select the sale?
Are you going to display a select dropdown menu, with options of parent "sale" posts, in the filter form?
If it is, there is a build-in feature within Views, see below test site:
hidden link
user/pass: xgren/111111

see the dropdown menus (State and City) in home page, screenshot 57.JPG

using below View:
hidden link

in section "Query Filter", use below filter:
Select posts that are children of the Post with ID set by the URL parameter wpv-pr-child-of.
eg. hidden link

in section "", use below codes to display the dropdown menus:

[wpv-control-set url_param="wpv-pr-child-of" ancestors="state>city" format="%%NAME%%"]
                        <div class="col-xs-6">
                          <label>[wpml-string context="wpv-views"]State[/wpml-string]</label>
                        
	[wpv-control-item type="select" ancestor_type="state" default_label="-- State --"]
                 
                        </div>
                        <div class="col-xs-6">
                           <label>[wpml-string context="wpv-views"]City[/wpml-string]</label>
                      [wpv-control-item type="select" ancestor_type="city" default_label="-- City --"]

                        </div>
                        [/wpv-control-set]

More help:
https://toolset.com/documentation/views-shortcodes/#wpv-control-set
This shortcode is a wrapper for the [wpv-control-item] shortcodes generated when displaying a parametric search that uses a filter by post relationship.

It has some attributes that hold important data for those inner shortcodes.

#374010

HI Luoy

I think I got it now.

I noticed on your dev site you had a post relationship filter which I wasn't using.

You can close the thread.

Thank you.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.