Created
August 15, 2017 13:38
-
-
Save philiprabbett/87a7480af5362ab154b4819d66c9c859 to your computer and use it in GitHub Desktop.
Change post type label strings referencing 'Post(s)' to 'News' in Wordpress
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 characters
| <?php | |
| /** | |
| * Change post type label strings referencing 'Post(s)' to 'News' in Wordpress | |
| * | |
| * @param object $labels Current post type labels | |
| * @return object Modified post type labels | |
| * @since 3.5.0 | |
| * | |
| * @source https://stackoverflow.com/a/44315084 | |
| */ | |
| add_filter( 'post_type_labels_post', 'change_post_labels', 10, 1); | |
| function change_post_labels( $labels ) { | |
| foreach( $labels as $key => $label ){ | |
| $labels->{$key} = str_replace( [ __( 'Posts' ), __( 'Post' ) ], __( 'News' ), $label ); | |
| } | |
| return $labels; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment