Problem: I have 4 categories: articles, video, audio, events.
I am searching for free text "basketball".
I want the results to show:
Results for "basketball" under "articles":
article-1, article-2, article 3
Results for "basketball" under "videos":
video-1, video-2, video-3
Results for "basketball" under "audio":
audio-1, audio-2, audio-3
Results for "basketball" under "events":
event-1, event-2, event-3
Solution:
There is not a good way to split up a single custom search View this way. Instead, you could use 4 separate custom search Views, each filtered by a single term. Then you can use conditional HTML to show and hide each View based on a URL parameter.
Add this custom shortcode to inspect URL parameters:
function exists_in_repeating_url_param_func($atts) { $var = $atts['var']; $test = $atts ['test']; $exists = isset($_GET[$var]) ? in_array( $test, $_GET[$var] ) : 0; return $exists; } add_shortcode("exists_in_repeating_url_param", "exists_in_repeating_url_param_func");
Use it like this:
[exists_in_repeating_url_param var="wpv-post-typer" test="video"]
If the URL includes "wpv-post-typer%5B%5D=video", this shortcode will return 1. If not, the shortcode will return null. You can use the value of this shortcode to determine whether or not to display each View.
Relevant Documentation:
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/using-shortcodes-in-conditions/
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.
Hoy no hay técnicos de soporte disponibles en el foro Juego de herramientas. Siéntase libre de enviar sus tiques y les daremos trámite tan pronto como estemos disponibles en línea. Gracias por su comprensión.
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)
Este tema contiene 7 respuestas, tiene 2 mensajes.
Última actualización por hace 6 años, 9 meses.
Asistido por: Christian Cox.