WordPress rename/change Post name to a different post type

There are times when you wold like to rename the default posts to something else. For example, I used a WordPress installation to created a real estate related website from a standard WordPress install.

I needed to add a custom post houses so that the client would be able to add the content to the website, but on the other hand I did not need to use the standard post type since I did not need the blog or news section. So why not convert it to something else.

Here is a simple way to do it. Note that this only changes the Posts name to Houses and does not change the posts  slug to houses . So if you ever refer to the house post type in your coding you will still refer to “posts”. This also maintain any changes and customization that the theme made to the post type. Hope this is clear enough.

You can use the php print_r function to print all the array, just in case you will need to change some other value.

After I updated my child-theme function .php , the standard WordPress post type changed to my custom house type. Note that if you do not have a child theme, you can use your theme main function php or just create a simple plugin. There are lots of advantages saving all your modification in your own plugin. One is that you youre changes will persist while changing the theme. On the other hand you can easily migrate your changes to a different blog or website. But this is just another subject.

So let’s continue customizing the new transformed post type. Now it is called Houses and it has to be reflected in the fields structure. For this I have installed a plugin called Advanced Custom Fields from the free WordPress repo.

advanced custom fields wordpress plugin

Please note that I am not related with the author of this plugin in any way

You have a large variety of field types you can create like you can see above. Just choose the one you need and follow the on-screen instruction.

wordpress custom fields type

Another cute feature that you have is the conditional logic. Used well this is a really powerful tool for creating dynamic fields on backend.

wordpress custom fields condicional logic

So I have created the fields set that I needed and assign them to my newly created post type. Remember that the new House is still a post type. So I will be assigning this to my “posts”.

house custom type add new fields

Great!!! Now I have my posts called house and have a new set of custom fields assigned to them. But wold like to replace the main editor with my own customized one.

So here is how I do it in my child theme function.php.

Later edit: I have realized that the plugin has an option to hide fields that you do not want to be displayed on the edit post screen. So you can use that instead to hide the main editor or any other metabox you don’t want there.

Later you will have to retrieve all this field values on your theme’s front-end. But I’m not there yet. I will write a tutorial about this at a later time.

 

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *

4 × three =