Toolset

Toolset: Búsquedas personalizadas con checkboxes y relación AND

add_filter( 'wpv_filter_query', 'wpv_atributs_serveis_negocis_wp', 99, 3 );
function wpv_atributs_serveis_negocis_wp( $query_args, $view_settings, $view_id ) {
    if ($view_id == 3900 && isset($_GET['wpv-wpcf-altres-serveis-del-negoci'])) {
         
        $my_args = array('relation' => 'AND');
        foreach($_GET['wpv-wpcf-altres-serveis-del-negoci'] as $offre){
            $my_args[] = array(
                'key'     => 'wpcf-altres-serveis-del-negoci',
                'value'   => $offre,
                'compare' => 'LIKE',
            );
        }
        $query_args['meta_query'][] = $my_args;
        foreach($query_args['meta_query'] as $k=>$v){
            if(isset($v['key']) && $v['key'] == 'wpcf-altres-serveis-del-negoci'){
                unset($query_args['meta_query'][$k]);
            }
        }
    }
    return $query_args;
}

Nota: wpv-wpcf-altres-serveis-del-negoci es el parámetro URL y wpcf-altres-serveis-del-negoci es el nombre del campo personalizado.

Visto en https://toolset.com/forums/topic/how-to-filter-by-more-than-one-checkbox/#post-631805

Toolset: personalizar filtro de distancia

Q1) style distance filter
You can use CSS codes to style the distance filter field, for example:

input.js-toolset-maps-distance-value{
  /* here add your custom CSS codes*/
}

Q2) translate the distance filter
You can change the placeholder text «Show results within… » and «Use my location» text manually by setup the shortcode attributes «inputs_placeholder» and «visitor_location_button_text», for example:

[wpv-control-distance inputs_placeholder="MY OWN Show results within %%DISTANCE%% of %%CENTER%%" visitor_location_button_text="MY OWN Use my location" ...]

Q4) Where can i delete the input fielt of km and mi?
There isn’t such a built-in feature within Toolset maps plugin, but you can hide it with some CSS codes, for example:

select.js-toolset-maps-distance-unit{
display:none;
}

Visto en https://toolset.com/forums/topic/style-map-distance-filter/

Toolset: mostrar el rol de usuario en un bucle de una vista de usuarios

Add the following custom shortcode to your functions.php file:

function get_user_role_func( $atts )
{
  $a = shortcode_atts( array(
      'userid' => ''
  ), $atts );
  $userdata = get_user_by('ID', $a['userid']);
  $user_roles = $userdata->roles;
  $user_role = array_shift($user_roles);
  return $user_role;
}
add_shortcode( 'get_user_role', 'get_user_role_func' );

Then in your View, use the shortcode in a conditional like this:

[wpv-conditional if="( '[get_user_role userid='[wpv-user field='ID']']' eq 'editor' )"]
I am Editor
[/wpv-conditional]
[wpv-conditional if="( '[get_user_role userid='[wpv-user field='ID']']' eq 'administrator' )"]
I am Admin
[/wpv-conditional]

Register «get_user_role» in Toolset > Settings > Frontend Content > Third party shortcode arguments.

Visto en Toolset

Toolset: Mostrar relevancia de los resultados

add_shortcode( 'show_results_relevance', 'show_results_relevance_func');
function show_results_relevance_func($atts) {
    // get the searched terms for main ingredients
    $searched_recipe_main_ingredient = do_shortcode('[wpv-search-term param="wpv-main-ingredient"]');
    if(!empty($searched_recipe_main_ingredient))
    {
        $searched_recipe_main_ingredient_arr = explode(", ", $searched_recipe_main_ingredient);
        // count of searched main ingredients
        $searched_recipe_main_ingredient_count = count($searched_recipe_main_ingredient_arr);
  
        // get attached main ingredients for current post
        $attached_main_ingredients = do_shortcode("[wpv-post-taxonomy type='main-ingredient' format='name' separator=', ']");
  
        if(!empty($attached_main_ingredients))
        {   
            $attached_main_ingredients_arr = explode(", ", $attached_main_ingredients);
             
            // count of common ingredients which were searched and are also attached
            $matched_main_ingredients = count(array_intersect($searched_recipe_main_ingredient_arr,$attached_main_ingredients_arr));        
        }
        else
        {
            $matched_main_ingredients = 0;
        }
  
    }
    else
    {
        $searched_recipe_main_ingredient_count = 0;
        $matched_main_ingredients = 0;
    }
  
 
 
 
    return ($matched_main_ingredients/$searched_recipe_main_ingredient_count*100);
 
}

Visto en Toolset

View select all in filter and live search

<input type="checkbox" id="selecctall_neighborhood" name="selecctall_neighborhood" value="selecctall_neighborhood" class="js-wpv-filter-trigger" [wpv-conditional if=" ('[wpv-search-term param="selecctall_neighborhood"]' eq 'selecctall_neighborhood') "]checked="checked"[/wpv-conditional] />
jQuery( document ).on( 'js_event_wpv_parametric_search_results_updated', function( event, data ) {
    /**
    * data.view_unique_id (string) The View unique ID hash
    * data.layout (object) The jQuery object for the View layout wrapper
    */
    $('#selecctall_neighborhood').click(function(event) {  //on click 
        if(this.checked) { // check select status
            $('#check_neighborhood .js-wpv-filter-trigger').each(function() { //loop through each checkbox
                this.checked = true;  //select all checkboxes with class "checkbox_neighborhood"               
            });
        }else{
            $('#check_neighborhood .js-wpv-filter-trigger').each(function() { //loop through each checkbox
                this.checked = false; //deselect all checkboxes with class "checkbox_neighborhood"                       
            });         
        }
    });
});

Visto en Toolset

Scroll al inicio

We are using cookies on our website

Please confirm, if you accept our tracking cookies. You can also decline the tracking, so you can continue to visit our website without any data sent to third party services.