search form on results page
-
Hi,
I have added the shortcode on the results page, but the search is not working. It works perfectly when you search at first though, without results already displaying.
Here is the code from my functions.php to style my results page.
add_filter('ajax_wpqsf_reoutput', 'customize_output', '', 2); function customize_output($results , $args){ // The Query $key2="duration"; $key3="period"; $key4="price"; $query = new WP_Query( $args ); echo '<div id="left-area">'; ob_start(); $results =''; // The Loop if ( $query->have_posts() ) { while ( $query->have_posts() ) { $query->the_post(); global $post; $thePostID = $post->ID; echo '<div><h3 style="font-weight: normal;">'.get_the_title().'</h3>'; echo the_excerpt(); echo '<strong style="padding-left:25px">Operator</strong>:'; $post_object = get_field('touroperator'); if( $post_object ): // override $post $post = $post_object; setup_postdata( $post ); echo '<a href="';the_permalink(); echo '">'; the_title(); echo '</a>'; wp_reset_postdata(); // IMPORTANT - reset the $post object so the rest of the page works correctly endif; echo ' <strong style="padding-left:25px">Duration</strong>: ';echo get_post_meta($thePostID, $key2, true); echo ' days <strong style="padding-left:25px">Period</strong>: '; echo get_post_meta($thePostID, $key3, true); echo ' <strong style="padding-left:25px">Price</strong>: '; echo get_post_meta($thePostID, $key4, true); echo '<a href="';the_permalink(); echo '">Find out more and book</a></div>'; } } else { echo 'no tours found'; } echo '</div><div id="sidebar">'; echo do_shortcode("[AjaxWPQSF id=6094]"); echo '</div></div>'; /* Restore original Post Data */ wp_reset_postdata(); $results = ob_get_clean(); return $results; }
Any help very much appreciated!
https://www.ads-software.com/plugins/ajax-wp-query-search-filter/
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘search form on results page’ is closed to new replies.