Support

Account

Forum Replies Created

  • I’ve implemented this as outlined in the link but when you collapse an item the title loses the sub_field data until you refresh the page again. Screengrab attached and my code below:

    
    function my_acf_flexible_content_layout_title( $title, $field, $layout, $i ) {
    
      if( $text = get_sub_field('anchor_name') ) {
        $title = '<strong>' . $text . '</strong> - <em>'.$title.'</em>';
      }  
    
      return $title; 
    }
    add_filter('acf/fields/flexible_content/layout_title/name=content_blocks', 'my_acf_flexible_content_layout_title', 10, 4);
    

    This is problematic since users will likely collapse as they go and then re-order.

    Any idea why this is happening?

  • Ok I think I figured it out:

    It’s not ACF breaking it, though it’s related. ‘wp_update_term’ if you don’t specify a value for an argument it uses the default. So my guess is it’s grabbing what’s in the database already and overriding what you’ve specified in the form.

    A work-around, is instead of using the ‘wp_update_term’ function is to just do:

      global $wpdb;
      $wpdb->update($wpdb->terms, array('term_group' => $value), array('term_id'=>$term_id));
Viewing 3 posts - 1 through 3 (of 3 total)