Toolset

Toolset: Select2

jQuery(document).ready(function() {
    jQuery('#desplegabledir select').select2();
});

Añadir select2 en un desplegable de toolset. Els desplegable tiene id y css class desplegabledir.

<link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css" rel="stylesheet" />
<script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script>

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

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.