Skip to content

Instantly share code, notes, and snippets.

@ziodave
Created December 13, 2021 15:40
Show Gist options
  • Save ziodave/a989f71b61064453152a6fc4fde639ea to your computer and use it in GitHub Desktop.
Save ziodave/a989f71b61064453152a6fc4fde639ea to your computer and use it in GitHub Desktop.
<?php
function set_rows( $selector, $value = array(), $post_id = false ) {
// filter post_id
$post_id = acf_get_valid_post_id( $post_id );
// get field
$field = acf_maybe_get_field( $selector, $post_id, false );
// bail early if no field
if ( ! $field ) {
return false;
}
// update value
acf_update_value( $value, $post_id, $field );
// return
return count( $value );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment