Toolset

Showing posts in calendar view based on start of the day

add_shortcode('ts_day_week_start', function($atts){
    $atts = shortcode_atts( array(
        'day' => 'Monday',
    ), $atts);
    $res = strtotime('last ' . $atts['day']);
    if(date('l') == $atts['day']){
        $res = strtotime('this ' . $atts['day']);
    }
    return $res;
});
 
 
add_shortcode('ts_day_week_end', function($atts){
    $atts = shortcode_atts( array(
        'day' => 'Monday',
    ), $atts);
    $res = strtotime('last ' . $atts['day']);
    if(date('l') == $atts['day']){
        $res = strtotime('this ' . $atts['day']);
    }
    $res = strtotime("tomorrow", $res) - 1;
    return $res;
});
[wpv-view name="schedule-view" cached="off" tsstart="[ts_day_week_start day='Friday']" tsend="[ts_day_week_end day='Friday']"]

Visto en Toolset

Toolset: Update Title and Slug of Post with Custom Field Content when post saves in the WordPress backend

add_filter( 'wp_insert_post_data' , 'set_issue_title' , '10', 3 );
  
function set_issue_title( $data , $postarr ) {
if ( 'my_post_type' != $data['post_type'] )
return $data;
  
$post_title = $data['post_title'];
  
if ( ! $post_title ) {
  
$issue_number = trim( $_POST['wpcf']['single1'] ); 
$issue_type = trim( $_POST['wpcf']['single2']);
  
$issue_title = $issue_type . ' - ' . $issue_number;
$post_slug = sanitize_title_with_dashes ($issue_title,'','save');
$post_slugsan = sanitize_title($post_slug);
  
$data['post_title'] = $issue_title;
$data['post_name'] = $post_slugsan;
  }
  
return $data;
}

Visto en https://toolset.com/forums/topic/use-custom-field-to-set-title-slug/

Revisar este otro post: https://toolset.com/forums/topic/use-custom-fields-to-set-post-title-and-post-slug/

Toolset: Auto Generate Post Title and Name/Slug by Combining Other Fields

add_action('cred_save_data', 'build_post_title', 10, 2);
function build_post_title($post_id, $form_data) {
 
if ($form_data['id']==9999) {
$field1 = get_post_meta($post_id, 'wpcf-street_address', true);
$field2 = get_post_meta($post_id, 'wpcf-city_address', true);
$term_list = wp_get_post_terms($post_id, 'state-address', array("fields" => "names"));
$terms = join("-",$term_list);
$field4 = get_post_meta($post_id, 'wpcf-zip_address', true);
 
$post_title=$field1.'-'.$field2.'-'.$terms.'-'.$field4;
$slug = sanitize_title($post_title);
wp_update_post(array('ID'=>$post_id, 'post_title'=>$post_title,'post_name' => $slug));
}
}

Visto en https://toolset.com/forums/topic/auto-generate-post-title-and-nameslug-by-combining-other-fields/

Toolset: Author frontend filtering with views and ajax

add_shortcode("list-of-authors", "list_of_authors");
function list_of_authors() {
  $out = '<option value="">All</option>';
  $users = get_users();
  foreach ($users as $user) {
    $selection = (isset($_GET['author-filter']) ? $_GET['author-filter']: '');
    $out .= '<option ' . selected($user->ID, $selection, false) . ' value="' . $user->ID . '">' . $user->display_name . '</a>';
  }
  return $out;
<select name="author-filter" class="js-wpv-filter-trigger">[list-of-authors]</select>

Visto en: https://toolset.com/forums/topic/author-frontend-filtering-with-views-and-ajax/

Toolset:. Populate custom field with post title

function tssupp_set_pp_title ( $post_id, $post, $update ) {
  $field_slug = 'practice-point-title';
  $post_type_slug = 'practice-point';
    
  // - bail on wrong post type or on pre-publish auto draft title
  $post_type = get_post_type( $post_id );
  $post_title = get_the_title( $post_id );
  if ( ( $post_type !== $post_type_slug ) || ( $post_title == 'Auto Draft') )  {
    return;
  }
    
  update_post_meta( $post_id, 'wpcf-' . $field_slug, get_the_title( $post_id ) );
}
    
add_action( 'save_post', 'tssupp_set_pp_title', 100, 3);

Visto en https://toolset.com/forums/topic/populate-custom-field-with-post-title/

Toolset: Different Custom Marker in a map based on a custom taxonomy

Solution: Add the following custom shortcode to determine how many terms are assigned to the current post in the loop:

function ts_get_post_tax_term_count_func( $atts ) {
  
  $a = shortcode_atts( array(
      'postid' => '0',
      'taxonomy' => null ), $atts
  );
  
  $terms = wp_get_post_terms( $a['postid'], $a['taxonomy']);
  return is_wp_error( $terms ) ? 0 : sizeof($terms);
}
  
add_shortcode( 'ts_get_post_tax_term_count', 'ts_get_post_tax_term_count_func');

Go to Toolset > Settings > Frontend content, and register both «has_term» and «ts_get_post_tax_term_count_func» to be used in conditionals and in 3rd party shortcode arguments. Then use the custom shortcode in combination with has_term to display the proper markers:

Multiple types:
[wpv-conditional if="('[ts_get_post_tax_term_count postid='[wpv-post-id]' taxonomy='facebook-type']' gt '1')"]https://www.tripup.it/wp-content/plugins/toolset-maps/resources/images/markers/MULTIPLE-MARKER.png[/wpv-conditional]
  
Only one type - arte-e-intrattenimento:
[wpv-conditional if="('[ts_get_post_tax_term_count postid='[wpv-post-id]' taxonomy='facebook-type']' eq '1') AND (has_term('arte-e-intrattenimento', 'facebook-type', null) eq '1')"]https://www.tripup.it/wp-content/uploads/2018/02/marker_shopping_web_white.png[/wpv-conditional]
  
Only one type - ospitelita:
[wpv-conditional if="('[ts_get_post_tax_term_count postid='[wpv-post-id]' taxonomy='facebook-type']' eq '1') AND (has_term('ospitelita', 'facebook-type', null) eq '1')"]https://www.tripup.it/wp-content/uploads/2018/02/OSPITELITA-MARKER.png[/wpv-conditional]
  
... copy and paste the block above for each facebook-type...
  
No types:
[wpv-conditional if="( [ts_get_post_tax_term_count postid='[wpv-post-id]' taxonomy='facebook-type']  eq '0')"]https://www.tripup.it/wp-content/plugins/toolset-maps/resources/images/markers/default.png[/wpv-conditional]

Visto en 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/

Ir arriba

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.