Pawan Kumawat

Sort A ACF Repeater Field Results

Sometimes getting ACF result is not enough. We may need to modify , filter or may be some other action. for that we need to use a ACF hook which is called ” ‘acf/load_value’” . my example is regarding sorting the result according to our choice . but we can use it to modify content.

Filters the field $value after being loaded.


apply_filters( 'acf/load_value', $value, $post_id, $field );


$value (mixed) The field value.
$post_id (int|string) The post ID where the value is saved.
$field (array) The field array containing all settings.


This filter provides modifiers to target specific fields. The following filter names are available:

   acf/load_value Applies to all fields.
   acf/load_value/type={$type} Applies to all fields of a specific type.
   acf/load_value/name={$name} Applies to all fields of a specific name.
   acf/load_value/key={$key} Applies to all fields of a specific key.


function my_acf_load_value( $value, $post_id, $field ) {
   $order = array();
   foreach( $value as $i => $row ) {
      $order[ $i ] = strtolower($row['field_612f382fb1ad5']);//field key
  array_multisort( $order, SORT_ASC, $value );
  return $value;
add_filter('acf/load_value/name=keyword_name', 'my_acf_load_value', 10, 3);

my_acf_load_value( $value, $post_id, $field ) {
    if( is_string($value) ) {
        $value = str_replace( 'Old Company Name', 'New Company Name',  $value );
    return $value;

// Apply to all fields.
add_filter('acf/load_value', 'my_acf_load_value', 10, 3);

// Apply to textarea fields.
// add_filter('acf/load_value/type=textarea', 'my_acf_load_value', 10, 3);

// Apply to fields named "hero_text".
// add_filter('acf/load_value/name=hero_text', 'my_acf_load_value', 10, 3);

// Apply to field with key "field_123abcf".
// add_filter('acf/load_value/key=field_123abcf', 'my_acf_load_value', 10, 3);


More you can check on full article by ACF team



Related Blogs

Top Quick View Plugins WooCommerce

There are several popular WooCommerce quick view plugins that provide a convenient way for customers to view product details without leaving the current page. Keep in mind that the popularity of plugins can change over time, so it’s a good idea to check for the latest information and reviews before making a decision.

WooCommerce: Check if Product Category is in the Cart

To check if a specific product category is in the cart during the `woocommerce_before_cart` action hook, you can use a similar approach as in the previous answer. However, in this case, you need to use the `woocommerce_before_cart_contents` action hook, which fires before the cart items are displayed on the cart page. Here’s how you can achieve this: