I need to apply a category filter onload rather than showing all categories. I’ve used the below code to set the default to ‘news’ and removed the all option. But it still loads all the posts rather than just the news post on load.
Nearly any value in any input object can be changed if you dig deep enough into the $input_object there are all kinds of things that can be changed.
Tested locally, and updated to match your field name _sfm_precio, this should do the trick:
function filter_range_dropdown($input_object, $sfid)
{
if($input_object['name']=='_sfm_precio')
{
//udpate this field before rendering
//if we want to filter the options generated, we need to make sure the options variable actually exists before proceeding (its only available to certain field types)
if(!isset($input_object['options']))
{
return $input_object;
}
//now loop through the options in the field
foreach($input_object['options'] as $option)
{
//update every label, and prefix and suffix with $
$option->label = "$ ".$option->label." $";
}
}
//always return the input object, even if we made no changes
return $input_object;
}
add_filter('sf_input_object_pre', 'filter_range_dropdown', 10, 2);
At this time, it is possible to add CSS identifiers (IDs and Classes) only to the term elements, and not the containing form elements. It is a feature we plan to add to the next major update (V3), which we are currently working on.
As to the first part of the question above, try changing the type of form field to Checkbox or radio and see if that looks closer in terms of the HTML structure. For me it does.
As to the second part, I understand. In your UL example, if that field had a filter selected, it would be the li that has the extra class to show it is selected, but CSS allows you to target the parent of an element that has a given class (in this case it would be the class sf-option-active). You can hide the checkbox with custom CSS as well.
I tried using CSS, unfortunately Macs/ Safari refuse to honor display:none;
Regarding the code
// add indent to dropdown
function filter_function_name($input_object, $sfid87) //I cant change it to just 87 as its expecting a variable
{
if($input_object[‘name’]==’_my_field_name’) // this should be the class name?
{
//udpate this field before rendering
$input_object = ” “. $input_object;
}
return $input_object;
}
add_filter(‘sf_input_object_pre’, ‘filter_function_name’, 10, 2); // what is 10,2 is that something that I should be changing?
My php isn’t that great, would it would be something like;
function filter_function_name($input_object, $sfid=87)
{
if($input_object[‘name’]==’sf-level-1′)
{
//udpate this field before rendering
$input_object[‘attributes’][‘style’] = ‘margin-left:50px;’;
}
// Search Filter
function filter_input_object($input_object, $sfid) {
if(($input_object['name'] == '_sfm_workshop_location') || ($input_object['name'] == '_sfm_tour_style') || ($input_object['name'] == '_sfm_tour_leader')) {
$new_options = array(); //the options added to this will replace all existing optoins in the field
foreach($input_object['options'] as $option) {
if ($option->value !== "")
{
//check to see if the option has a parent
$parent_id = wp_get_post_parent_id($option->value);
if(!$parent_id)
{
//then this option does not have a parent, so it must be a parent itself, add it to the new array
$option->label = get_the_title($option->value);
array_push($new_options, $option);
}
}
}
//now we have an array with only parent options in, so simply replace the one in the input object
$input_object['options'] = $new_options;
}
return $input_object;
}
add_filter('sf_input_object_pre', 'filter_input_object', 10, 2);
Any ideas?
Author
Search Results
Viewing 10 results - 111 through 120 (of 150 total)
This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.
We also use cookies to store items in your cart as well as allowing your to login on the site.
You can adjust all of your cookie settings by navigating the tabs on the left hand side.
By continuing to use this site, you also agree to our Privacy Policy.
Strictly Necessary Cookies
Strictly Necessary Cookie should be enabled at all times so that we can save your preferences for cookie settings.
*Other cookies used for logging in and cart functions will only be used when you use those features and cannot be disabled.
If you disable these cookie, we will not be able to save your preferences. This means that every time you visit this website you will need to enable or disable cookies again.
3rd Party Cookies
This website uses Google Analytics to collect anonymous information such as the number of visitors to the site, and the most popular pages.
Keeping this cookie enabled helps us to improve our website.
Please enable Strictly Necessary Cookies first so that we can save your preferences!