Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Wordpress - Renaming the 'Posts' post type?

Featured Replies

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?

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' );

  • 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... :huh:

Edited by Spitfire

Hmmmm... Now you mention it. He is awfully good at it and we've never seen them in the same room together... :huh:

 

 

post-21712-0-81962400-1329131102_thumb.png Busted.

Edited by Renaissance-Design

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.