Skip Navigation

[Resolved] Como hacer que en una pagina de búsqueda no me salgan por defecto resultados

This support ticket is created 4 years, 10 months 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 2 replies, has 2 voices.

Last updated by Miguel 4 years, 10 months ago.

Assisted by: Nigel.

Author
Posts
#2028417
Captura de pantalla 2021-04-21 a las 11.39.15.png

Tell us what you are trying to do?
Buenos días estoy intentando que no me salgan en la página de búsqueda los resultados hasta que no se haga una selección.
Con el código que les muestro mas abajo me funciona pero me aparece los botones de anterior y siguiente antes de hacer la selección. Les adjunto imagen.

Is there any documentation that you are following?
Si he usado la informacion de la siguiente url https://toolset.com/forums/topic/como-hacer-que-en-una-pagina-de-busqueda-no-me-salgan-por-defecto-resultados/

Is there a similar example that we can see?
Estoy usando el siguiente código. en al pestaña de código personalizado
<?php
/**
* New custom code snippet (replace this with snippet description).
*/

toolset_snippet_security_check() or die( 'Direct access is not allowed' );

// Put the code of your snippet below this comment.

function tssupp_no_initial_results( $query_results, $view_settings, $view_id ){

$target_views = array( 6303, 7216 ); // Comma-separated list of View IDs

if ( in_array( $view_id, $target_views ) ) {

// if there is a search term set
if ( !isset( $query_results->query['meta_query'] ) && !isset( $query_results->query['tax_query'] ) && !isset( $query_results->query['s'] ) ) {
$query_results->posts = array();
$query_results->post_count = 0;
$query_results->found_posts = 0;
}
}

return $query_results;
}
add_filter( 'wpv_filter_query_post_process', 'tssupp_no_initial_results', 10, 3 );

What is the link to your site?
hidden link

#2029355

Nigel
Supporter

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

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

Hola Miguel

Ya no recomendamos usar código particular para implementar este, se puede con el GUI.

Ve https://toolset.com/course-lesson/creating-a-custom-search/#hide-the-search-results-until-the-first-search

Debes movar el bloque de paginación dentro del bloque condicionál también.

Si usas el editor clásico, puedes hacer lo mismo con el shortcode wpv-conditional.

Debes envolcrar el loop dentro de la condición, así:

[wpv-layout-start]
	[wpv-items-found]
	[wpv-conditional if="( '[wpv-search-term param='wpv_view_count']' ne '' )"]
	<!-- wpv-loop-start -->
		<wpv-loop>
          <h3>[wpv-post-link]</h3>
		</wpv-loop>
	<!-- wpv-loop-end -->
	[/wpv-conditional]
	[/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]

También, donde sea que metas la paginación debes envolcrar sus shortcodes con una condición igual que arriba.

#2029509

My issue is resolved now. Thank you!