Skip Navigation

[Resolved] add a filter with post id

This support ticket is created 5 years ago. 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.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

This topic contains 7 replies, has 2 voices.

Last updated by ericW-5 5 years ago.

Assisted by: Nigel.

Author
Posts
#1393171
FILTRE.PNG

On a job site, I have a view where all job offers are listed. Each job offered has a ref ID which is the post ID (circled in yellow on the attached image)

People can filter this list by job category, also can filter by typing the title of the job offer.
I would need people to find a job offer also filtering by Ref ID (= post ID)

E.g.: they type 3545 and hit search and they find the job offer which has 3545 as post ID in the search results.

How can I do that ?
Thanks in advance

*** Here is my current filter ***

[wpv-filter-start hide="false"]
[wpv-filter-controls]
<div class="filtre2">
<div class="form-group">
<label for="wpv-wpcf-categorie">[wpml-string context="wpv-views"]Catégorie[/wpml-string]</label>
[wpv-control-postmeta field="wpcf-categorie" type="select" default_label="Toutes" url_param="wpv-wpcf-categorie"]
</div>
<div class="form-group">
<label for="wpv-wpcf-budget">[wpml-string context="wpv-views"] Budget[/wpml-string]</label>
[wpv-control-postmeta field="wpcf-budget" type="select" default_label="Tous" url_param="wpv-wpcf-budget"]
</div>
<div class="form-group">
<label for="wpv-post-search">[wpml-string context="wpv-views"]Titre[/wpml-string]</label>
[wpv-filter-search-box placeholder="titre de la mission" output="bootstrap"]
</div>

[wpv-filter-submit name="Rechercher" output="bootstrap"]
</div>

[/wpv-filter-controls]
[wpv-filter-end]

#1393407

thanks in advance for your help

#1393413

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Front end filtering is only supported for custom fields and taxonomies, not for standard post fields such as ID.

However, it is possible to include a Query Filter for the post ID that will listen for a URL parameter, so insert that, and note that it will suggest by default a URL parameter of post_ids.

Now we need to add front end controls where your users can input an ID to search by.

You can use the wpv-control shortcode to effectively fake a front-end filter, that is, it will include the control and pass the search input as a URL parameter.

So manually add the following to your Search and Pagination editor together with your other controls (you'll want to add a label to the field, etc.):

[wpv-control field="nosuchfield" type="textfield" url_param="post_ids"]

That should be all that's required.

#1393435

Thanks for the reply

But I understand I should set permalinks to %post_id% (instead of post name) for this to work... which means all my pages permalink would also change ? If it is the case this would be problematic in terms of SEO.

Regards

#1393445

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

I'm not sure why you think that, it's not necessary.

#1393475

Here is my new filter which includes your proposed code, but unfortunately the filter does not work, I may have missed something... Here is the page hidden link
When I input a reference, say 3565, the filter does not select this unique job offer

Thanks in advance

[wpv-filter-start hide="false"]
[wpv-filter-controls]
<div class="filtre2">
<div class="form-group">
<label for="wpv-wpcf-categorie">[wpml-string context="wpv-views"]Catégorie[/wpml-string]</label>
[wpv-control-postmeta field="wpcf-categorie" type="select" default_label="Toutes" url_param="wpv-wpcf-categorie"]
</div>
<div class="form-group">
<label for="wpv-wpcf-budget">[wpml-string context="wpv-views"] Budget[/wpml-string]</label>
[wpv-control-postmeta field="wpcf-budget" type="select" default_label="Tous" url_param="wpv-wpcf-budget"]
</div>
<div class="form-group">
<label for="wpv-post-search">[wpml-string context="wpv-views"]Titre de l'offre[/wpml-string]</label>
[wpv-filter-search-box placeholder="tapez le titre" output="bootstrap"]
</div>
<div class="form-group">
<label for="wpv-post-search">[wpml-string context="wpv-views"]Reference[/wpml-string]</label>
[wpv-control field="nosuchfield" type="textfield" url_param="post_ids"]
</div>
[wpv-filter-submit name="Rechercher" output="bootstrap"]
</div>

[/wpv-filter-controls]
[wpv-filter-end]

#1393477

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Screenshot 2019-11-27 at 15.25.58.png

Did you add a Query Filter for post ID?

#1393643

My issue is resolved now. Thank you!