I have a WordPress parent theme that uses a custom post type called portfolio
, which I’d like to change to property
.
I’d like to have all of the contextual elements changed to show property
like, "show properties"
, "add new property"
, "delete property"
, etc.
I know I can do this by updating the parent theme, but I’d prefer not to, if I can avoid it.
I found this answer, but unfortunately, I’m not PHP savvy enough to write my own function and change this.
Can someone help me out with this? I’m kind of stuck.
I have a feeling this is something simple for a PHP Dev. I just don’t know how to do it.
$wp_post_types
is a global array that holdspost_type
objects, which in turn have alabels
property.You can change
$wp_post_types[$post_type]->labels
after the parent theme has set the CPT.Add higher priority to
init
hook.Add the following code in your theme’s
functions.php
file.For more information, check out the codex article on
get_post_type_object
.Add following code in
functions.php
to replace main menu label from sidebarAdd following code in
functions.php
for adding image to admin sidebar CPT menuThis changes the labels and the menu name. Also a bonus to change the slug too.
This example changes a registered post type called ‘services’ to ‘specialty’ (American English spelling).
Change the labels and the name all at once:
Bonus: Change the slug. Don’t forget to save your permalinks after this is added.