Last active
August 18, 2024 12:00
-
-
Save philhoyt/11ab22518aa26fedeb89867a228ea53f to your computer and use it in GitHub Desktop.
Revisions
-
philhoyt revised this gist
Apr 29, 2022 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,4 @@ <?php /** Create Title and Slug */ function acf_title( $value, $post_id, $field ) { if ( get_post_type( $post_id ) === 'staff' ) { -
philhoyt revised this gist
Apr 29, 2022 . 1 changed file with 12 additions and 11 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,17 +1,18 @@ /** Create Title and Slug */ function acf_title( $value, $post_id, $field ) { if ( get_post_type( $post_id ) === 'staff' ) { $new_title = get_field( 'first_name', $post_id ) . ' ' . $value; $new_slug = sanitize_title( $new_title ); wp_update_post( array( 'ID' => $post_id, 'post_title' => $new_title, 'post_name' => $new_slug, ) ); } return $value; } add_filter( 'acf/update_value/name=last_name', 'acf_title', 10, 3 ); -
philhoyt created this gist
Dec 13, 2016 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,17 @@ // Create Title and Slug function acf_title( $value, $post_id, $field ) { if ( get_post_type( $post_id ) == 'staff' ) { $new_title = get_field('first_name', $post_id) . ' ' . $value; $new_slug = sanitize_title( $new_title ); // update post wp_update_post( array( 'ID' => $post_id, 'post_title' => $new_title, 'post_name' => $new_slug, ) ); } return $value; } add_filter( 'acf/update_value/name=last_name', 'acf_title', 10, 3 );