Created
August 17, 2016 22:22
-
-
Save portegno/a0a953fd4a7ba789444eeccfa3bf69a1 to your computer and use it in GitHub Desktop.
Actualizar title con campos de ACF al grabar o actualizar Post
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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