WordPress’ custom post types are a fantastic way to organise different types of data. It’s quick and easy to spin up a new post type with just a couple of lines of code. Post types can be used to store anything from products, forms, profiles or even logs, pretty much any type of content stored in a repeatable way.
However one of the more time consuming aspects of creating custom post types is setting all the correct labels. There are dozens of labels used for each post type, all used in different contexts. For the best administrative user experience all the labels should be configured, but often they can be overlooked.
To aid with the creation of post type labels, simply drop this function into your functions.php file or custom plugin. From there, you can simply call this function, passing through the singular and plural labels, and the rest will be generated for you. And if needed, individual labels can be overwritten.
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
Cameron Jones is a professional Web Developer and DevOps Engineer specialising in all things WordPress, and is the author of the popular Mongoose Page Plugin. When he's not working on a new website or WordPress plugin, he can be found on the sports field or in the mosh pit at a metal concert.
Subscribe To The Newsletter
Get the latest updates and exclusive offers direct to your inbox