-
AuthorSearch Results
-
July 25, 2016 at 10:51 am #52078
In reply to: Getting value from url
TrevorParticipantThis?
<?php //Get a multiple fields values by passing an array of field names //replace 1526 with the ID of your search form global $searchandfilter; $sf_current_query = $searchandfilter->get(15)->current_query(); print_r($sf_current_query->get_fields_html(array(), array('show_all_if_empty' => false))); ?>
July 25, 2016 at 10:43 am #52076In reply to: Getting value from url
TrevorParticipantI see the error. My bad for copying and pasting. The forum has changed the quotes 🙁
<?php //Get a multiple fields values by passing an array of field names //replace 1526 with the ID of your search form global $searchandfilter; $sf_current_query = $searchandfilter->get(15)->current_query(); print_r $sf_current_query->get_fields_html(array(), array('show_all_if_empty' => false)); ?>
Or, I hope that is it.
July 25, 2016 at 10:39 am #52072In reply to: Getting value from url
AnonymousInactiveIf I use this code:
<?php //Get a multiple fields values by passing an array of field names //replace 1526 with the ID of your search form global $searchandfilter; $sf_current_query = $searchandfilter->get(15)->current_query(); print_r $sf_current_query->get_fields_html(array(), array(‘show_all_if_empty’ => false)); ?>
It “breaks” the page…?
July 25, 2016 at 10:36 am #52071In reply to: Getting value from url
TrevorParticipantI need to see the array structure to know which element to grab. This code instead of the current echo should give the array:
print_r $sf_current_query->get_fields_html(array(), array(‘show_all_if_empty’ => false));
July 22, 2016 at 3:42 pm #51940In reply to: Getting value from url
AnonymousInactive<?php echo $sf_current_query->get_fields_html(array("_sft_aantal_personen","_sft_arrangementstype","_sft_type_boot","_sft_type_boot_2","_sft_boot_opties"), array('show_all_if_empty' => false)); ?>
This…
July 22, 2016 at 3:16 pm #51933In reply to: Getting value from url
AnonymousInactiveHi Trevor,
I think it’s this part:
<?php //Get a multiple fields values by passing an array of field names //replace 1526 with the ID of your search form global $searchandfilter; $sf_current_query = $searchandfilter->get(15)->current_query(); ?> <?php $arrangement = $sf_current_query->get_fields_html(array("_sft_aantal_personen","_sft_arrangementstype","_sft_type_boot"), array('show_all_if_empty' => false)); ?>
I like to keep my echo’s separate from the rest… so I can echo them where ever I like.
July 22, 2016 at 9:41 am #51898In reply to: Getting value from url
AnonymousInactiveHi Trevor, I got it to work.
Using this code:function refresh() { $('.things').load(document.URL + ' .things'); } //detects the start of an ajax request being made $(document).on("sf:ajaxstart", ".searchandfilter", function(){ console.log("ajax start"); }); //detects when the ajax request has finished and the content has been updated // - add scripts that apply to your results here $(document).on("sf:ajaxfinish", ".searchandfilter", function(){ console.log("ajax complete"); //so load your lightbox or JS scripts here again refresh(); }); //an event fired when S&F is initialised and S&F scripts have been loaded $(document).on("sf:init", ".searchandfilter", function(){ console.log("S&F JS initialised"); });
The only thing is, it posts the whole category and name: Aantal personen: 20 of meer personen. You’ve already tackelled this problem here: https://support.searchandfilter.com/forums/topic/how-to-style-the-search-data/
global $searchandfilter; $sf_current_query = $searchandfilter->get(339)->current_query()->get_array(); foreach($sf_current_query as $key) { echo '<div>' . $key['active_terms'][0]['name'] . '</div>'; }
Which would display “20 of meer personen” but What I would like is to have it show “Aantal personen:<br />20 of meer personen.
What to do?
July 20, 2016 at 5:38 pm #51738In reply to: Shortcode results: don't display results until click
TrevorParticipantHi
I found two errors (one was ours, one yours), so here is the fixed code (I do not know if this will work):
<?php /** * Search & Filter Pro * * Sample Results Template * * @package Search_Filter * @author Ross Morsali * @link http://www.designsandcode.com/ * @copyright 2015 Designs & Code * * Note: these templates are not full page templates, rather * just an encaspulation of the your results loop which should * be inserted in to other pages by using a shortcode - think * of it as a template part * * This template is an absolute base example showing you what * you can do, for more customisation see the WordPress docs * and using template tags - * * http://codex.wordpress.org/Template_Tags * */ if ( $query->have_posts() ) { global $searchandfilter; $sf_current_query = $searchandfilter->get(44)->current_query(); if ($sf_current_query->is_filtered()) { ?> <?php echo $query->found_posts; ?> Firm(s) Meet All Selected Criteria<br/> <div class="pagination"> <div class="nav-previous"><?php next_posts_link('Older posts', $query->max_num_pages); ?></div> <div class="nav-next"><?php previous_posts_link('Newer posts'); ?></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> <h6><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h6> <p><?php the_tags(); ?></p> </div> <hr/> <?php } ?> <div class="pagination"> <div class="nav-previous"><?php next_posts_link('Older posts', $query->max_num_pages); ?></div> <div class="nav-next"><?php previous_posts_link('Newer posts'); ?></div> <?php /* example code for using the wp_pagenavi plugin */ if (function_exists('wp_pagenavi')) { echo "<br />"; wp_pagenavi(array('query' => $query)); } ?> </div> <?php } else { echo "No firms meet all of your criteria. Try unchecking some boxes."; } } ?>
May 29, 2016 at 3:20 pm #46964In reply to: displaying search terms without labels
AnonymousInactivegot it! here is the solution.
<?php global $wp_query; $sf_current_query = $wp_query->query_vars['_sft_position']; ?> <?php if (isset ($sf_current_query)) : ?> <?php echo '<span class="results-term">' . $sf_current_query . '</span>'; ?> <?php endif; ?>
the vars can be changed to any search term you have.
May 29, 2016 at 10:20 am #46959In reply to: displaying search terms without labels
TrevorParticipantOK
I have re-written that a bit and added a new line after each line output. It may not work, but it is better code:
<?php global $searchandfilter; $sf_current_query = $searchandfilter->get(2327)->current_query()->get_array(); if (isset ($sf_current_query)) { foreach($sf_current_query as $key) { echo '<span class="results-term">' . $key['active_terms'][0]['name'] . '</span><br />'; } } ?>
-
AuthorSearch Results