-
AuthorSearch Results
-
September 8, 2016 at 7:47 pm #57011
In reply to: Preselecting taxonomy?
AnonymousInactiveOk, so I managed selecting the checkbox with some jQuery added via functions.php:
//Select sector in posts filter add_action('wp_footer', 'sectorpostsfilter'); function sectorpostsfilter(){ if (function_exists('get_field')) : $sectorobject = get_field('taxonomy_sector'); $sectorid = $sectorobject->term_id; if ($sectorid) : ?> <script type='text/javascript'> jQuery = jQuery.noConflict(); jQuery(function( $ ) { $('.sf-item-<?php echo $sectorid; ?> input').prop('checked', true); }); </script><?php endif; endif; }
And by altering the query within the template:
<?php if (function_exists('get_field')) : $sectorobject = get_field('taxonomy_sector'); $sectorslug = $sectorobject->slug; endif; $loop = new WP_Query( array( 'sectors' => $sectorslug ) ); while ( $loop->have_posts() ) : $loop->the_post(); get_template_part( 'loop', 'post' ); endwhile; wp_reset_postdata(); ?>
September 2, 2016 at 2:57 pm #56465In reply to: Extra space in search results
AnonymousInactiveThanks, I fixed that. Your plugin still adds extra paragraph tags and br tags.
<?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() ) { ?> Found <?php echo $query->found_posts; ?> Results<br /> Page <?php echo $query->query['paged']; ?> of <?php echo $query->max_num_pages; ?><br /> <div style="width:100%;"> <?php while ($query->have_posts()) { $query->the_post(); ?> <div class="result"> <div class="photo"> <?php if (get_field('property_main_image') != '') { ?> <img src="<?php the_field('property_main_image'); ?>" alt="<?php get_field('address'); ?>" /> <?php } else { ?> <img src="/CreativeHomes/wp-content/uploads/2016/08/image-placeholder-500x500.jpg" alt="image coming soon" /> <?php } ?> </div> <div class="status"><?php echo get_field('status'); ?></div> <div class="details"> <?php echo '<h4>$' . get_field('price') . ' </h4>'; echo '<p>' . get_field('address') . '<br>'; echo get_field('city') . ', '; echo get_field('state'); echo get_field('zip') . '</p>'; echo '<p class="spex">' . get_field('bedrooms') . ' BEDROOMS • '; echo get_field('bathrooms') . ' BATHROOMS<br>'; echo '<span class="secondline">' . get_field('square_footage') . ' SQ FT • '; echo get_field('garages') . ' CAR GARAGE</span>'; echo '<span>MLS# ' . get_field('MLS') . '</span></p>';?> <div class="linx"> <a href="#"><img src="/CreativeHomes/wp-content/uploads/2016/08/CH_Button_Photos_Grey.png" alt="see photo gallery" /></a> <a target="_blank" href="<?php echo get_field('map_it_link'); ?>"><img src="/CreativeHomes/wp-content/uploads/2016/08/CH_Button_MapPin_Grey.png" alt="google map for location" /></a> <a target="_blank" href="<?php echo get_field('download_floorplan'); ?>"><img src="/CreativeHomes/wp-content/uploads/2016/08/CH_Button_Collateral_Grey.png" alt="brochure download" /></a> </div><!--end linx--> <a href="<?php echo get_permalink(); ?>"><img src="/CreativeHomes/wp-content/uploads/2016/08/details-button.png" width="122" alt="details" /></a> </div><!--end details--> <div class="interact"> <span><?php the_favorites_button($post_id, $site_id); ?></span> <span><img src="/CreativeHomes/wp-content/uploads/2016/08/check-icon.jpg" />Compare</span> <span><?php if ( function_exists( 'ADDTOANY_SHARE_SAVE_KIT' ) ) { ADDTOANY_SHARE_SAVE_KIT(); } ?>Share</span> <div class="clearfix"> </div> </div><!--end interact--> </div><!--end result--> <?php } ?> </div> <?php } else { echo "No Results Found"; } ?>
September 2, 2016 at 2:54 pm #56464In reply to: Extra space in search results
TrevorParticipantI can see a coding error on line 46:
<?php if (get_field('property_main_image') != '') { ?>
This
if
is started, but not ended. It needs to end before line 93.September 2, 2016 at 1:50 pm #56455In reply to: Extra space in search results
AnonymousInactive<?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() ) { ?> Found <?php echo $query->found_posts; ?> Results<br /> Page <?php echo $query->query['paged']; ?> of <?php echo $query->max_num_pages; ?><br /> <div style="width:100%;"> <?php while ($query->have_posts()) { $query->the_post(); ?> <div class="result"> <?php if (get_field('property_main_image') != '') { ?> <img />" alt="" width="400px" /> <div class="status"><?php echo get_field('status'); ?></div> <div class="details"> <?php echo '<h4>$' . get_field('price') . ' </h4>'; echo '<p>' . get_field('address') . '<br>'; echo get_field('city') . ', '; echo get_field('state'); echo get_field('zip') . '</p>'; echo '<p class="spex">' . get_field('bedrooms') . ' BEDROOMS | '; echo get_field('bathrooms') . ' BATHROOMS<br>'; echo '<span class="secondline">' . get_field('square_footage') . ' SQ FT | '; echo get_field('garages') . ' CAR GARAGE</span>'; echo '<span>MLS# ' . get_field('MLS') . '</span></p>';?> <div class="linx"> <a href="#"><img src="/CreativeHomes/wp-content/uploads/2016/08/CH_Button_Photos_Grey.png" alt="see photo gallery" /></a> <a target="_blank">"><img src="/CreativeHomes/wp-content/uploads/2016/08/CH_Button_MapPin_Grey.png" alt="google map for location" /></a> <a target="_blank">"><img src="/CreativeHomes/wp-content/uploads/2016/08/CH_Button_Collateral_Grey.png" alt="brochure download" /></a> </div><!--end linx--> <a>"><img src="/CreativeHomes/wp-content/uploads/2016/08/details-button.png" width="122" alt="details" /></a> </div><!--end details--> <div class="interact"> <span><?php the_favorites_button($post_id, $site_id); ?></span> <span><img src="/CreativeHomes/wp-content/uploads/2016/08/check-icon.jpg" />Compare</span> <span><?php if ( function_exists( 'ADDTOANY_SHARE_SAVE_KIT' ) ) { ADDTOANY_SHARE_SAVE_KIT(); } ?>Share</span> </div><!--end interact--> </div><!--end result--> <?php } ?> </div> <?php } else { echo "No Results Found"; } ?>
August 30, 2016 at 10:17 am #56017In reply to: Echo value from checked box
TrevorParticipantIn PHP you need to take the string and modify it. The first thing is to remove the
Location:
string. So, you use the PHP Search function to find the:
, like this:$return_string = $sf_current_query->get_fields_html(array("_sft_locatie"); $colon_pos = strpos($return_string, ":");
Then you fetch the right most part of the return_string after the colon:
$return_string_trim = substr($return_string, $colon_pos+1);
Then you replace the commas with
<br />
:$return_string_html = str_replace(",", "<br />", $return_string_trim);
And then you return the string:
return $return_string_html;
At least, I think ….
August 29, 2016 at 9:37 am #55931Topic: Echo value from checked box
in forum Search & Filter Pro
AnonymousInactiveSo this is kind of similar to a question I’ve already asked. But now I’m struggling with the styling of the echo.
To echo the checked boxes I use the following code:
function locaties_search() { global $searchandfilter; $sf_current_query = $searchandfilter->get(3403)->current_query(); return $sf_current_query->get_fields_html(array("_sft_locatie"), array('show_all_if_empty' => false)); } add_shortcode('locatiesearch', 'locaties_search');
And then I use the following shortcode to echo the results:
<?php echo do_shortcode('[locatiesearch]'); ?>
Right now it’s displaying the results like:
Location:Location-x, Location-yWhat I would like is to have it just echo like so:
Location-x
Location-yWhat code should I use?
July 25, 2016 at 10:51 am #52078In 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));
-
AuthorSearch Results
-
Search Results
-
Topic: Echo value from checked box
So this is kind of similar to a question I’ve already asked. But now I’m struggling with the styling of the echo.
To echo the checked boxes I use the following code:
function locaties_search() { global $searchandfilter; $sf_current_query = $searchandfilter->get(3403)->current_query(); return $sf_current_query->get_fields_html(array("_sft_locatie"), array('show_all_if_empty' => false)); } add_shortcode('locatiesearch', 'locaties_search');
And then I use the following shortcode to echo the results:
<?php echo do_shortcode('[locatiesearch]'); ?>
Right now it’s displaying the results like:
Location:Location-x, Location-yWhat I would like is to have it just echo like so:
Location-x
Location-yWhat code should I use?