Skip to content

Instantly share code, notes, and snippets.

@portegno
Created August 17, 2016 22:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save portegno/a0a953fd4a7ba789444eeccfa3bf69a1 to your computer and use it in GitHub Desktop.
Save portegno/a0a953fd4a7ba789444eeccfa3bf69a1 to your computer and use it in GitHub Desktop.
Actualizar title con campos de ACF al grabar o actualizar Post
function actualizar_titulos( $post_id ) {
// Custom Post type al que deseamos alterar cuando se graba un nuevo post
if ( get_post_type($post_id) == 'proyectos' ) {
$my_post = array();
$my_post['ID'] = $post_id;
$my_post['post_title'] = get_field( 'nombre', $post_id );
// actualizar el post en la base
wp_update_post( $my_post );
}
}
// correr luego de que ACF grabe el $_POST['fields']
add_action('acf/save_post', 'actualizar_titulos', 20);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment