-
Search Results
-
Topic: Not working on page load
Hello Team,
No matter where I search, I can’t find a way to make the plugin run on page load.
Once I start clicking around, the ajax filtering works fine, but I need it to work on the first page load too.
We are using the code below to remove one of the options and to set the default active item. This all works fine.
// Remove “All Courses” option and set main to default on Our Menu.
add_filter( ‘sf_input_object_pre’, function ( $input_object, $sfid ) {
if ( $sfid == 120 ) {
// var_dump($input_object);
if ( ( $input_object[‘name’] = ‘_sft_course’ ) ) {
if ( empty( $input_object[‘defaults’][0] ) ) {
$input_object[‘defaults’] = [ ‘main’ ];
}
$key = array_search( ‘All Courses’, array_column( $input_object[‘options’], ‘label’ ) );
if ( $key !== false ) {
unset( $input_object[‘options’][ $key ] );
$input_object[‘options’] = array_values( $input_object[‘options’] );
}
}
}return $input_object;
}, 10, 2 );Can you please tell me how to instruct the plugin to run in the fresh page load?
I can’t find the answer anywhere in the docs or internet.Thank you very much,
KotaTopic: Wrap filter items in a div
Hi, I’m trying to wrap
<li>items in the filter in a div so I can easily apply an accordion to them. I’ve been using sf_input_object_pre to modify the prefix and postfix but they don’t seem to insert anything into the HTML – can someone confirm what these attributes do? And if they don’t insert any prefix or postfix, is there a way I can add HTML to the filter list?
Thanks.function filter_function_name($input_object, $sfid) { if($input_object['type']!='checkbox') { return $input_object; } foreach($input_object['options'] as $key => $option) { if ($option->attributes['class']="sf-level-0") { $input_object['options'][$key]->prefix = '<div>'; $input_object['options'][$key]->postfix= '</div>'; } } return $input_object; } add_filter('sf_input_object_pre', 'filter_function_name', 10, 2);

