How to rename the default posts-type Posts label for display on the front end


I have several Custom Post Types and regular WP Posts all feeding into a main archive page called 'news'.

The CPT are for different areas but still under news and the core Posts are for the Blog.

I am using the below code to display the name of the post type on archive page excerpts (eg. events, awards). What I want to do is have the blog 'posts' display 'Blog' Instead of 'Posts' which they currently are doing.

<?php $post_type = get_post_type_object( get_post_type($post) ); echo $post_type->label ; ?>

Open in new window

I have renamed 'posts' to 'blog' in the admin area but it is still displaying 'posts' as the post type on the front end and I'm not sure how to change this.

Can anyone please advise how to fix this?

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jason C. LevineDon't talk to me.Commented:
Can you give us a link or a screenshot that illustrates the problem?  Having a hard time following this from text only.
igloobobAuthor Commented:
Hi Jason,
sure thing. Here is a screenshot, I have hidden all the actual post content but you can see here are 3 excerpts on my main news page. The news page shows all posts plus all my custom post types. Here you can see Events & Webcasts and Awards which are CPTs. Then there is one 'Posts' which is my regular posts. However, I have renamed these Blog for this website so I need to change this front end display from Posts to Blog.

I have Blog showing everywhere else back end and in the urls.

Does that make sense?

Thanks for taking a look.
Jason C. LevineDon't talk to me.Commented:
So the blog posts are or are not a CPT?
Exploring ASP.NET Core: Fundamentals

Learn to build web apps and services, IoT apps, and mobile backends by covering the fundamentals of ASP.NET Core and  exploring the core foundations for app libraries.

igloobobAuthor Commented:
no, the blog posts are the standard core WP 'posts', I just renamed them 'blog'.
Jason C. LevineDon't talk to me.Commented:
How did you do that?
igloobobAuthor Commented:
I added this to functions.php to change the labels in the admin area:

function edit_admin_menus() {
    global $menu;
    $menu[5][0] = 'Blog Posts'; // Change Posts to Blog Posts
add_action( 'admin_menu', 'edit_admin_menus' );

Open in new window

Then I changed the custom permalinks to:


'newsroom' is my top level page on which I am displaying excertps from the blog (regular posts) and all the CPTs. So 'newsroom' is an archive for all those post types together. Then each of the post types has its own archive page.
Jason C. LevineDon't talk to me.Commented:
I figured it was something like that, thanks for confirming.

So that function changes the label in the admin, does nothing to the actual post type.  If you look in the wp-content table in the MySQL, you will see your blog posts still listed as "post" in there and that's why the front end continues to show "Posts"

Given what you have already done, I would simply create a new CPT for your Blogs and then use

to migrate your posts to the blog CPT.  Trying to force WordPress do change its Posts to something else is a much harder fight, possibly an impossible one.
Jason C. LevineDon't talk to me.Commented:
I guess the other way to do it would be something like this:

$post_type = get_post_type_object( get_post_type($post) ); 
if ( $post_type->label == "Post" ) { //or Posts or whatever it is.
     echo "Blog";
} else {
     echo $post_type->label ; 

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
igloobobAuthor Commented:
This worked a treat thank you! I think I might look to change it to a CPT as you suggested above but have one for the quick fix for now.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.