-
Search Results
-
Hi I have an issue with Search and Filter where if I try to have two Taxonomy filters it causes a glitch where I have to click the checkbox twice to get it to change the results.
The reason for having two filters for the same Taxonomy is one is a dropdown and the other is a checkbox. I want to hide the checkbox on mobile and display the dropdown for mobile devices as the checkboxes cause too much clutter. However with this glitch it makes this approach impossible.
Is there an alternative to having an alternate search style on mobile.
Thanks,
JanekI need to remove the ?sf_action=get_data&sf_data=all&sf_paged=2 from my page urls.
I am loading search results via Ajax and infinite scroll. When the infinite scroll is triggered, all posts that are loaded have that query string appended—this is breaking critical redirects.
How do I prevent this from happening?
I have already added this function to my functions.php
function _remove_script_version( $src ){
$parts = explode( ‘?’, $src );
return $parts[0];
}
add_filter( ‘script_loader_src’, ‘_remove_script_version’, 15, 1 );
add_filter( ‘style_loader_src’, ‘_remove_script_version’, 15, 1 );I inherited this site from another developer and do not usually work in wordpress or php.
2 scenarios:
#1: Infinite scroll container is specified: results will quickly load (as many as I specify per page,) it will hit the infinite scroll trigger at the bottom, trigger loading icon, and then nothing more comes back.
#2: No infinite scroll container is specified: Infinite scroll will load all results at the normal rate per page ie) 7 results per page, but the trigger happens at almost every scroll, even when I’m scrolling toward the top of the page. I think it may be a problem with how the containers are specified and maybe a naming conflict. I’ve tried many different values for offset but it doesn’t seem to make a difference. I saw others requesting a ‘load more results’ button and wondered if that was possible yet?
I’m also open to trying it with pagination, but when I try to implement, it seems like its trying to do some string parsing with the url which initially does not have a query string so I get
cannot read property split() of undefined
. thanks so much for your insight!Here are the two files this is happening in:
<?php /** * The template used for displaying page content for the Big Green Database * * @package red_underscores */ // Determine which resource page this is $page_id = get_the_ID(); $page_name = ''; if ( $page_id == 12614) { $page_name = 'garden'; // Your Edible School Garden (cat = garden-skills-resources) $lessons_id = 12612; $sf_form_id = 14035; } if ( $page_id == 12612 ) { $page_name = 'lessons'; // Garden Lessons + Curriculum (cat = curriculum-lessons-activities) $garden_id = 12614; $sf_form_id = 14036; } ?> <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>> <?php $featured = wp_get_attachment_image_src( get_post_thumbnail_id(), 'full'); $overlay_background = "linear-gradient(rgba(255, 255, 255, 0), rgba(255, 255, 255, 0))"; ?> <div class="featured main" style="background: <?php echo $overlay_background ?>, url('<?php echo $featured[0] ?>'); min-height: 720px;"> <div class="grid-container featured-content"> <?php the_title( '<h1 class="entry-title">', '</h1>' ); ?> </div> </div><!-- featured --> <div class="grid-container"> <div class="entry-content grid-60 prefix-20 tablet-grid-90 tablet-prefix-5"> <?php the_content(); ?> </div><!-- .entry-content --> </div> <?php // Toggle between pages ?> <div class="grid-container"> <?php ?> </div> <?php // Display at most three highlighted resources from this main category $main_resource_category = ''; switch ($page_name) { case 'lessons': $main_resource_category = 'curriculum-lessons-activities'; break; case 'garden': $main_resource_category = 'garden-skills-resources'; break; } $args = array( 'post_type' => 'resource', 'posts_per_page' => 3, 'tax_query' => array( array( 'taxonomy' => 'resource-category', 'field' => 'slug', 'terms' => $main_resource_category ) ), ); // Display remaining results (not highlighted) via search & filter ?> <div class="sf-results-container"> <div class="grid-container"> <?php echo do_shortcode( '[searchandfilter id="'.$sf_form_id.'"]' ); ?> </div> <div class="dotted-border"></div> <div class="grid-container grid-of-posts resources"> <div class="grid-33 push-66 sf-pop-sidebar"> <h3>Popular Collections:</h3> <div class="dotted-border"></div> <div id="popular-collections-remote-control"></div> </div> <div class="grid-66 pull-33 two-col-results search-filter-results-list"> <?php echo do_shortcode( '[searchandfilter id="'.$sf_form_id.'" show="results"]' ); ?> </div> <div class="pagination"> Found <?php echo $query->found_posts; ?> Results<br /> Page <?php echo $query->query['paged']; ?> of <?php echo $query->max_num_pages; ?><br /> <?php wp_pagenavi(); ?> <?php /* example code for using the wp_pagenavi plugin */ if (function_exists('wp_pagenavi')) { echo "<br />"; wp_pagenavi( array( 'query' => $query ) ); } ?> </div> </div> </div> </div> <script> (function($) { // Load again after ajax to work after filtering results $(document).on("sf:ajaxfinish", ".searchandfilter", function(){ // Place search and filter boxes within grid $("li.sf-field-post-meta-resource_subjects, li.sf-field-taxonomy-grade-level, li.sf-field-search, li.sf-field-taxonomy-resource-category, li.sf-field-post-meta-content_source, li.sf-field-post-meta-grade_level_range, li.sf-field-submit").addClass('grid-33 tablet-grid-50 mobile-grid-100'); }); $(document).ready(function() { // Get list of labels and inputs in .sf-field-post-meta-popular_collection_tag var labels = $('.sf-field-post-meta-popular_collection').find('label'); var inputs = $('.sf-field-post-meta-popular_collection').find('input'); // Append them to the #popular-collections-remote-control div for ( var i = 0; i < labels.length; i++ ) { var selectedClass = ''; // Apply selected class to anything that's selected on load if(inputs[i].checked) { selectedClass = 'selected'; } $('#popular-collections-remote-control') .append( '<div class="target '+ selectedClass +'" id="' + inputs[i].value + '">' + labels[ i ].innerHTML + '</div><div class="dotted-border"></div>'); } // Set up remote control clicks $('#popular-collections-remote-control .target').click(function() { var targetValue = $(this).attr('id'); $(this).toggleClass('selected'); $(':checkbox[value=' + targetValue + ']').trigger('click'); }); // Place search and filter boxes within grid $("li.sf-field-post-meta-resource_subjects, li.sf-field-taxonomy-grade-level, li.sf-field-search, li.sf-field-taxonomy-resource-category, li.sf-field-post-meta-content_source, li.sf-field-post-meta-grade_level_range, li.sf-field-submit").addClass('grid-33 tablet-grid-50 mobile-grid-100'); }); })(jQuery); </script> <footer class="entry-footer"> <?php //edit_post_link( esc_html__( 'Edit', 'red_underscores' ), '<span class="edit-link">', '</span>' ); ?> </footer><!-- .entry-footer --> </article><!-- #post-## -->
<?php /** * Search & Filter Pro * * Template for Filter Resources - Garden * */ if ( $query->have_posts() ) { ?> <?php while ($query->have_posts()) { $query->the_post(); ?> <div class="search-filter-result-item grid-50 tablet-grid-50 mobile-grid-100"> <?php get_template_part( 'template-parts/content', 'resource_overview' ); ?></div><?php } ?> <?php } else { ?> <div class='search-filter-results-list end-of-results' data-search-filter-action='infinite-scroll-end'> <p>no more results</p> </div> <?php } ?>
I’m building a site with events as a custom post type. For the archive page, I’d like to just have three buttons (or radio buttons that I can style) with “All”, “Upcoming”, and “Previous Events.” How can I get this to work using S&F Pro? I was able to do this with pure code, but could never get the pagination correct. Any help is appreciated.
Hey Trevor,
I’m trying to add style=”display: none;” to this line of code:
<ul data-operator=”and” class=””>I cannot find which file to make this edit in the Search and Filter plugin. It would be greatly appreciated if you could tell me which line and which file to edit.
Cheerss,
GaryI am having a searchbox in my website’s home page. When a user searches for any keyword then it shows the resultant articles with “Read More Articles” button as a pagination. I am using search.php file to display this result.
Q.1. Now I want to have additional filters like Searchbox and Dropdown with “Relevance” and “Date” sort order. How can I set this two dropdown with search field in my existing search result page along with same pagination style “Read More Articles” on the same page?
Q.2. I installed the Relevanssi Plugin and done the settings. Also enable the Relevanssi checkbox and Sort Results By relevance checkboxes under the Search Form->Advanced tab but When I try to search any keyword then I am not getting any result and previously I got the search results. What should be the issue? Am I doing something wrong?