-
Search Results
-
Hi there,
I have the following custom Search Results PHP file. Everything works great when the page loads but when AJAX call try to get a new result (After filter criteria change) result shows the content of the shortcode without parsing it properly. How can I enable
do_shortcodein AJAX?if ( $query->have_posts() ) { ?> Found <?php echo $query->found_posts; ?> Results<br /> Page <?php echo $query->query['paged']; ?> of <?php echo $query->max_num_pages; ?><br /> <div class="pagination"> <div class="nav-previous"><?php next_posts_link( 'Next Page', $query->max_num_pages ); ?></div> <div class="nav-next"><?php previous_posts_link( 'Previous Page' ); ?></div> </div> <?php while ($query->have_posts()) { $query->the_post(); global $parent; $parent = $query->post; echo do_shortcode(get_post_field('post_content', 1)); } ?> Page <?php echo $query->query['paged']; ?> of <?php echo $query->max_num_pages; ?><br /> <div class="pagination"> <div class="nav-previous"><?php next_posts_link( 'Next Page', $query->max_num_pages ); ?></div> <div class="nav-next"><?php previous_posts_link( 'Previous Page' ); ?></div> </div> <?php } else { echo "No Results Found"; }HI everyone, please i need your help….i tried work a lot of time in this…i need show results in three columns and three rows with pagination, but i can´t. I searched in google, forums, but i don’t find anything…
My live website is in:
https://sitio2.ferianacionalbahia.cl/resultados?G_sft_post_tag=region-metropolitanaI work with the file /templates/result.php
My code is…if ( ! defined( ‘ABSPATH’ ) ) {
exit;
}if ( $query->have_posts() )
{
?>Se encontraron <?php echo $query->found_posts; ?> resultados<br />
Página <?php echo $query->query[‘paged’]; ?> de <?php echo $query->max_num_pages; ?><br /><div class=”pagination”>
<div class=”nav-previous”><?php next_posts_link( ‘Siguiente’, $query->max_num_pages ); ?></div>
<div class=”nav-next”><?php previous_posts_link( ‘Anterior’ ); ?></div>
<?php
/* example code for using the wp_pagenavi plugin */
if (function_exists(‘wp_pagenavi’))
{
echo “<br />”;
wp_pagenavi( array( ‘query’ => $query ) );
}
?>
</div><?php
while ($query->have_posts())
{
$query->the_post();?>
<div id=”encontrados”>
<?php
if ( has_post_thumbnail() ) {
//echo ‘<p>’;
the_post_thumbnail(“thumbnail”);
//echo ‘</p>’;
}
?>
<p style=”text-align:right”><br /><?php the_excerpt(); ?></p>
<h3>“>Visitar su perfil…</h3>
</div>
<?php
}
?>
Página <?php echo $query->query[‘paged’]; ?> de <?php echo $query->max_num_pages; ?><br /><div class=”pagination”>
<div class=”nav-previous”><?php next_posts_link( ‘Siguiente’, $query->max_num_pages ); ?></div>
<div><p></p>
<div class=”nav-next”><?php previous_posts_link( ‘Anterior’ ); ?></div>
<?php
/* example code for using the wp_pagenavi plugin */
if (function_exists(‘wp_pagenavi’))
{
echo “<br />”;
wp_pagenavi( array( ‘query’ => $query ) );
}
?>
</div>
<hr>
<?php
}
else
{
echo “No se encontraron resultados”;
}
?>Hi The posts are displaying but no infinite scroll. Cannot see the loader either. Can you help?
Here’s what I have done:
1. Set settings as per https://searchandfilter.com/documentation/search-results/infinite-scroll/
screenshot here: https://imgur.com/vloOCYk2. Added shortcode to page
<?php echo do_shortcode('[searchandfilter id="2348" show="results"]'); ?>3. Created search-filter folder in theme, moved results-infinite-scroll.php to this folder and renamed results.php.
Here is the code (theme/search-filter/results.php):
<?php // If this file is called directly, abort. if ( ! defined( 'ABSPATH' ) ) { exit; } if ( $query->have_posts() ) { ?> Found <?php echo $query->found_posts; ?> Results<br /> <div class='search-filter-results-list'> <?php while ($query->have_posts()) { $query->the_post(); ?> <div class='search-filter-result-item'> <div style="padding: 5rem; background-color: lightblue; margin-bottom: 1rem;"> <p><?php the_title(); ?></p> </div> </div> <?php } ?> </div> <?php } else { ?> <div class='search-filter-results-list' data-search-filter-action='infinite-scroll-end'> <span>End of Results</span> </div> <?php } ?>Thanks for your help!
Hello.
The standard theme works fine, but the production theme gives 0 results.
I don’t know what caused it.Write down the contents of search.php
<?php
/**
* Luxeritas WordPress Theme – free/libre wordpress platform
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* @copyright Copyright (C) 2015 Thought is free.
* @license http://www.gnu.org/licenses/gpl-2.0.html GPL v2 or later
* @author LunaNuko
* @link https://thk.kanzae.net/
* @translators rakeem( http://rakeem.jp/ )
*/global $luxe, $s;
get_header();if( function_exists( ‘thk_search_result’ ) === false ) {
function thk_search_result() {
global $s, $wp_query; ?>
<p id=”list-title”><?php echo
sprintf( __( ‘Search results of [%s]’, ‘luxeritas’ ), esc_html( $s ) ) .
sprintf( __( ‘ : %s’, ‘luxeritas’ ), $wp_query->found_posts );
?></p><?php
}
}
?>
<input type=”hidden” id=”search-result” value=”<?php echo esc_html( $s ); ?>” />
<?php
if( !empty( $s ) && have_posts() === true ) {
?>
<div id=”section”<?php echo $luxe[‘content_discrete’] === ‘indiscrete’ ? ‘ class=”grid”‘ : ”; ?>>
<?php
get_template_part( ‘loop’ );
?>
</div><!–/#section–>
<?php
}
else {
?>
<article>
<div id=”core” class=”grid”>
<?php
if( $luxe[‘breadcrumb_view’] === ‘inner’ ) get_template_part( ‘breadcrumb’ );
?>
<div itemprop=”mainEntityOfPage” id=”post”>
<h2 id=”list-title”><?php echo __( ‘No search hits’, ‘luxeritas’ ); ?></h2>
<p><?php echo __(‘Sorry, the requested post was not found.’, ‘luxeritas’); ?></p>
</div><!–/#post–>
</div><!–/#core–>
</article>
<?php
}
?>
</main>
<?php thk_call_sidebar(); ?>
</div><!–/#primary–>
<?php echo apply_filters( ‘thk_footer’, ” ); ?>