February 12, 201214 yr I'm building quite a specific theme and after creating a few extra post types, the original 'Posts' post type doesn't really fit in with the rest of them - it's far too generic. Ideally I'd like to rename it to something like 'News' but I'm having a little trouble finding a decent way of doing it. I know there are a few plugins that can do it but I'd rather avoid them. Seems a bit of an overkill to use a plugin for this, plus I'll hopefully be marketing the theme so would rather have everything placed neatly in the functions.php instead of trying to bundle other people's plugins into my theme. The only half decent solution I've seen is a bit of a hack with translations, eg: add_filter( 'gettext', 'change_post_to_article' ); add_filter( 'ngettext', 'change_post_to_article' ); function change_post_to_article( $translated ) { $translated = str_ireplace( 'Post', 'News', $translated ); // ireplace is PHP5 only return $translated; } But that feels like a bit of a gaffer-tape solution. Anyone know of any other ways to do it?
February 12, 201214 yr What about manipulating the labels on init? function change_post_menu_label() { global $menu; global $submenu; $menu[5][0] = 'News'; $submenu['edit.php'][5][0] = 'News'; $submenu['edit.php'][10][0] = 'Add News'; $submenu['edit.php'][16][0] = 'News Tags'; echo ''; } function change_post_object_label() { global $wp_post_types; $labels = &$wp_post_types['post']->labels; $labels->name = 'News'; $labels->singular_name = 'News'; $labels->add_new = 'Add News'; $labels->add_new_item = 'Add News'; $labels->edit_item = 'Edit News'; $labels->new_item = 'News'; $labels->view_item = 'View News'; $labels->search_items = 'Search News'; $labels->not_found = 'No News found'; $labels->not_found_in_trash = 'No News found in Trash'; } add_action( 'init', 'change_post_object_label' ); add_action( 'admin_menu', 'change_post_menu_label' );
February 12, 201214 yr Brought to you by WordPress now using the same API to register built-in post types as it exposes for custom ones.
February 12, 201214 yr Author Chris/WordPress Hmmmm... Now you mention it. He is awfully good at it and we've never seen them in the same room together... Edited February 12, 201214 yr by Spitfire
February 12, 201214 yr Hmmmm... Now you mention it. He is awfully good at it and we've never seen them in the same room together... Ooo, the thick plottens...
February 12, 201214 yr Hmmmm... Now you mention it. He is awfully good at it and we've never seen them in the same room together... Busted. Edited February 13, 201214 yr by Renaissance-Design
Create an account or sign in to comment