-
AuthorSearch Results
-
November 30, 2016 at 5:43 pm #73321
In reply to: How to get Post Meta values?
AnonymousInactiveHi, we were able to get the meta values we needed with get_array();
And for those curious the code we used was (square-feet is our custom field):
<?php global $searchandfilter; $sf_current_query = $searchandfilter->get(315)->current_query(); $array_data = $sf_current_query->get_array(); $squarefeet_min = $array_data["_sfm_square-feet"]["active_terms"][0]["value"]; $squarefeet_max = $array_data["_sfm_square-feet"]["active_terms"][1]["value"]; ?>
Thanks again for the help.
November 17, 2016 at 4:38 pm #70909In reply to: Settings & Default / Post (wrong default order)
AnonymousInactivefunction sf_filter_query_args( $query_args, $sfid ) {
if($sfid==1225){
global $searchandfilter;
$sf_current_query = $searchandfilter->get(1225)->current_query();$sf_current_query->get_field_string(“_sfm_event_archives”);
$_sfm_event_archives_array = $sf_current_query->get_array();
$archive_is_check = $_sfm_event_archives_array[_sfm_event_archives][active_terms][0][value];//print_r($archive_is_check);
if($archive_is_check != ‘1’){
$args_custom = array(
“meta_key” => “imic_event_start_dt”,
“orderby” => “meta_value_num”,
“order” => “ASC”,
“meta_query” => Array (
“event_archives” => Array (
“key” => “event_archives”,
“value” => “0”
)
)
);$query_args = array_merge($query_args, $args_custom);
}// si aucun filtre d’appliqué
//if($sf_current_query->is_filtered()!=1){}}
return $query_args;
}
add_filter( ‘sf_edit_query_args’, ‘sf_filter_query_args’, 100, 2 );November 17, 2016 at 4:37 pm #70903In reply to: Settings & Default / Post (wrong default order)
AnonymousInactiveHi,
thanks for your help!!!
It wasn’t the wpml plugin,
but the custom code (that I was sure it wasn’t in cause)
I had to add the bold section here to make it workfunction sf_filter_query_args( $query_args, $sfid ) { if($sfid==1225){ global $searchandfilter; $sf_current_query = $searchandfilter->get(1225)->current_query(); $sf_current_query->get_field_string("_sfm_event_archives"); $_sfm_event_archives_array = $sf_current_query->get_array(); $archive_is_check = $_sfm_event_archives_array[_sfm_event_archives][active_terms][0][value]; //print_r($archive_is_check); if($archive_is_check != '1'){ $args_custom = array( <strong>"meta_key" => "imic_event_start_dt", "orderby" => "meta_value_num", "order" => "ASC",</strong> "meta_query" => Array ( "event_archives" => Array ( "key" => "event_archives", "value" => "0" ) ) ); $query_args = array_merge($query_args, $args_custom); } // si aucun filtre d'appliqué //if($sf_current_query->is_filtered()!=1){} } return $query_args; } add_filter( 'sf_edit_query_args', 'sf_filter_query_args', 100, 2 );
Thanks again for your help guys!
Really nice plugin!November 16, 2016 at 5:49 pm #70670In reply to: Hide initial results on first page load (continued)
AnonymousInactiveThanks for that! Got it working by testing for
($sf_current_query->get_field_string("_th_private_page_category")=="Page Categories: All Page Categories")
You can close this now, cheers.
November 16, 2016 at 5:17 pm #70658In reply to: Hide initial results on first page load (continued)
AnonymousInactiveNo I’m afraid not, it’s on the client server.
It looks like it might work if I knew how to check for contents of the categories and tags boxes instead of the text search field.
The code you provided looks like ($sf_current_query->get_search_term()==””) checks to see if the text search field is empty. Is there a similar query to check if the categories selection is empty? And the tags selection?
Many thanks.
November 16, 2016 at 2:55 pm #70563In reply to: Get date range from current archive.php url
AnonymousInactiveTrevor,
Between this and another support post that I located, this was indeed the solution:
$sarr = $sf_current_query->get_array();
$fromDate = $sarr[_sf_post_date][active_terms][0][value] ;
$toDate = $sarr[_sf_post_date][active_terms][1][value];Thanks!
November 16, 2016 at 2:04 pm #70549In reply to: Hide initial results on first page load
AnonymousInactiveHi again 🙂
What does the 1726 in the 2nd line of that code refer to? Is that a page ID?
$sf_current_query = $searchandfilter->get(1726)->current_query();
November 16, 2016 at 1:39 pm #70519In reply to: Get date range from current archive.php url
TrevorParticipantDo you know if you have the name correct? You could use PHP to dump the $sf_current_query array, like this:
echo '<pre>'; print_r($sf_current_query); echo '</pre>';
November 15, 2016 at 11:13 am #70334In reply to: Customisation of the search results page
TrevorParticipantOK. The >> is made by your theme and needs to be switched off inside search and filter forms, with Custom CSS:
.bSe .searchandfilter ul li::before {content: '' !important;}
To put the search field and button next to each other, this:
.searchandfilter .sf-field-search { display: inline-block; padding-left: 0 !important; margin-right: 20px; } .searchandfilter .sf-field-submit { display: inline-block; padding-left: 0 !important; }
For the second point, to hide results until a search has been made, I need to know you have placed a copy of the results.php file in your theme or child theme folder, as here:
Assuming that you have, edit that file and replace the content with this:
<?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 * */ global $searchandfilter; $sf_current_query = $searchandfilter->get(255)->current_query(); if ((!$sf_current_query->is_filtered())&&($sf_current_query->get_search_term()=="")) { echo '<div>Nothing to see here folks!</div>'; } else { 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( '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> <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2> <p><br /><?php the_excerpt(); ?></p> <?php if ( has_post_thumbnail() ) { echo '<p>'; the_post_thumbnail("small"); echo '</p>'; } ?> <p><?php the_category(); ?></p> <p><?php the_tags(); ?></p> <p><small><?php the_date(); ?></small></p> </div> <hr /> <?php } ?> 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( '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 Results Found"; } } ?>
That should work, I hope.
For #3. It would be better to use your theme’s own styling, and to do this I would need to see a more normal results page in your theme that looks OK to you, then we can borrow their styling.
November 8, 2016 at 6:39 pm #69273
RossKeymasterHey Kevin
Sorted it!
Basically what you had done was correct…
is_filtered
returns true if a filter has been selected.This is not true for the search term though, as its not regarded as a filter (perhaps it should be now that I think about it)…
So what I did was also add a condition to see if a user had typed a search term to your template, and now it works as expected –
$sf_current_query->get_search_term()==""
Best
-
AuthorSearch Results