Sarathlal N

Modify already registered post types - WordPress

In a recent WordPress project, I need to modify the menu label of an already registered post type. The post type was registered by a plugin & I need regular updates of that plugin. So I can’t edit the plugin.

Same situation happens before. Nowadays, too many premium plugins & themes will register various post types for the functionality. But client will argue that he need the perfect names in his dashboard.

After a quick search, I get an awesome WordPress function to modify already registered post type. You have to update below code snippet as per your post type.

add_action( 'registered_post_type', 'xaxo_post_type_tweak', 10, 2 );
/**
 * @param string $post_type Registered post type name. 
 * @param array $args Array of post type parameters.
 */
function xaxo_post_type_tweak( $post_type, $args ) {
	if ( 'your_posttype' === $post_type ) {
		global $wp_post_types;
		$args->labels->menu_name = __( 'New Menu Name', 'your_posttype' );
		$wp_post_types[ $post_type ] = $args;
	}
}

Looking for a skilled WordPress/WooCommerce developer? I'm currently available for freelance, contract, or full-time remote opportunities! Let's create something amazing together. Send me a quick message, and I'll respond within 24 hours!

Recent Posts

  1. Understanding the Singleton Pattern and Using Traits to Achieve Singleton in WordPress Plugin Development
  2. REST API Methods Explained with Best Practices for Building Clean and Secure APIs
  3. My 28-Day Plan to Master Modern WordPress Development Using AI Tools
  4. Scaling WordPress - How Custom Database Tables Solve the Post Meta Bottleneck
  5. WordPress Transients Explained - A Developer's Guide to Site Performance

Your Questions / Comments

If you found this article interesting, found errors, or just want to discuss about it, please get in touch.