Sauter la navigation

[Résolu] Display Search form for archive on different page

Ce fil est résolu. Voici une description du problème et la solution proposée.

Problem: I can see how to split the custom search form for a View apart from the results, and display them on separate pages. I would like to do the same but with an archive instead of a View.

Solution: There isn't a built-in way to split the search and results for an archive. You could do something similar with a View, or you could use custom code to build your own search form that submits to the archive page with URL parameters as needed.

This support ticket is created Il y a 6 années et 2 mois. 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
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

Ce sujet contient 4 réponses, a 3 voix.

Dernière mise à jour par PiotrO586 Il y a 6 années et 2 mois.

Assisté par: Christian Cox.

Auteur
Publications
#1137839

Hi,

I have an archive where I have a section displaying search form.
I'd like to display the search form related to the archive on the frontpage. I know this tutorial:
https://toolset.com/documentation/user-guides/front-page-filters/

I cannot see there how to do it. The page displaying the archive is not a regular page which can be selected as a target where to display the results.

#1138108

Yes, this requires a View, that is placed on a Page which you can choose as a target when inserting the View or Widget.

There is no possibility to link to an archive as a custom search like this.
It could be possible by crafting custom links that lead to the archive and pass the ?query_parameters to the URL which the Archive listens to.
However, that is not possible with the GUI process as inserting the View or Widget.
It would require you to build let's say a select field with a few values (which you can produce with a RAW Views Output for example), which then leads to the archive passing the selected values in the ?query_parameters to the URL which the Archive listens to.

Please let us know if you would need help with that.

#1139175

Hi Beda,

1. Sounds promising. So I'd see it as a simple form: a select field and a button. The select field should display categories (taxonomy) assigned to a given custom post. Clicking on the button should redirect to the archive page with filtered results based on the url parameter. I'd be grateful for hints.

2. This actually raises another question: what is an advantage of using WordPress Archive over standard view, if the latter one seems to be more flexible?

Best

#1139812

Clicking on the button should redirect to the archive page with filtered results based on the url parameter. I'd be grateful for hints.
It really depends on the complexity of the search form. If it's just the one select field filter, you could use this other ticket as a guide:
https://toolset.com/forums/topic/create-a-dropdown-box-with-location-names-to-select-a-location-then-display-it/
Your example will use variable URL parameters, not variable term archive URLs. If there are multiple filters, it's going to require a significant amount of custom code.

what is an advantage of using WordPress Archive over standard view
WordPress sets up archives automatically at specific URLs, so Toolset's WordPress Archives may be faster to implement because some of the system is automated. For example, you can use one WordPress Archive to display archives for each term in a taxonomy, without manipulating the Query Filters for the WordPress Archive.
yoursite.com/taxonomy-slug/term-slug
yoursite.com/taxonomy-slug/term-slug-2
yoursite.com/taxonomy-slug/term-slug-3
This pattern is common among WordPress sites, and the feed systems are set up to make these feeds available. If you wanted to accomplish this with Views, you would have to create custom Pages for each term, and then set up some way to manipulate the View's term query filter on each page, like a shortcode attribute or something, and they wouldn't be automatically available in archive feeds.

#1143212

Thank you guys, I will use these hints to figure something out.