回答:
カスタム投稿タイプを作成するのではなく、投稿の外観の名前を変更するだけの場合は、このコードをテーマのfunctions.phpファイルに追加します。
// hook the translation filters
add_filter( 'gettext', 'change_post_to_portfolio' );
add_filter( 'ngettext', 'change_post_to_portfolio' );
function change_post_to_portfolio( $translated ) {
$translated = str_ireplace( 'Post', 'Portfolio', $translated ); // ireplace is PHP5 only
return $translated;
}
透明性のために、この記事からこのコードを入手しましたが、以前にも同様のトリックを使用しました。
次のスクリプトを使用して、デフォルトの投稿タイプの名前を変更しました。
function change_post_menu_label() {
global $menu, $submenu;
$menu[5][0] = 'Portfolio';
$submenu['edit.php'][5][0] = 'Portfolio';
$submenu['edit.php'][10][0] = 'New Portfolio';
$submenu['edit.php'][16][0] = 'Portfolio Tags';
echo '';
}
add_action( 'admin_menu', 'change_post_menu_label' );
function change_post_object_label() {
global $wp_post_types;
$labels = &$wp_post_types['post']->labels;
$labels->name = 'Portfolio';
$labels->singular_name = 'Portfolio';
$labels->add_new = 'New Portfolio';
$labels->add_new_item = 'New Portfolio';
$labels->edit_item = 'Edit Portfolio';
$labels->new_item = 'New Portfolio';
$labels->view_item = 'View Portfolio';
$labels->search_items = 'Search Portfolio';
$labels->not_found = 'Not found';
$labels->not_found_in_trash = 'Not found in trash';
}
add_action( 'init', 'change_post_object_label' );
カスタム投稿タイプ「ポートフォリオ」を作成する必要があります。
投稿は投稿です。何もないものとしてそれらを使用することを試み、次に、1つまたは2つの単純な関数をで作成する代わりに、それらの命名法を変更しようとするfunctions.php
と、正確な機能と正確な命名法の両方が得られますか?
UPDATE wp_posts SET post_type = 'funny-bunny' WHERE post_type = 'post';
なります。現在のインストールでの設定を反映するには、テーブルのプレフィックス(wp_)を変更する必要があります。
// hook the translation filters
add_filter( 'gettext', 'change_post_to_article' );
add_filter( 'ngettext', 'change_post_to_article' );
function change_post_to_article( $translated ) {
$translated = str_ireplace( 'Post', 'Article', $translated ); // ireplace is PHP5 only
return $translated;
}
私はスマッシング雑誌からこのヒントを得てそれをテストしました、そしてそれは素晴らしい働きをします
http://www.smashingmagazine.com/2011/05/10/new-wordpress-power-tips-for-template-developers-and-consultants/
ポートフォリオの名前を変更する
function litho_posts_portfolio() {
global $menu;
global $submenu;
$menu[5][0] = __("Portfolio", 'litho');
$submenu['edit.php'][5][0] = __("Portfolio", 'litho');
$submenu['edit.php'][10][0] = __("New Item", 'litho');
echo '';
}
function litho_posts_portfolio_label() {
global $wp_post_types;
$labels = &$wp_post_types['post']->labels;
$labels->name = __("Portfolio", 'litho');
$labels->singular_name = __("Item", 'litho');
$labels->add_new = __("New Item", 'litho');
$labels->add_new_item = __("New Item", 'litho');
$labels->edit_item = __("Edit Item", 'litho');
$labels->new_item = __("Item", 'litho');
$labels->view_item = __("View Item", 'litho');
$labels->search_items = __("Search Portfolio", 'litho');
$labels->not_found = __("No Item Found", 'litho');
$labels->not_found_in_trash = __("No Item found in Trash", 'litho');
}
add_action( 'init', 'litho_posts_portfolio_label' );
add_action( 'admin_menu', 'litho_posts_portfolio' );
__()
機能。
echo '';
?
管理メニューのラベルを投稿->ポートフォリオから変更したいだけの場合は、次の質問を見てください。
[更新]
このプラグインの管理メニューエディターは、メニューラベルをより簡単に変更できるように見えますが、まだテストしていません。
通常の投稿と同じ機能を持つ別のカスタム投稿を作成する必要があります。次に、これを使用して[投稿]メニューを無効にできます。
function remove_menus()
{
global $menu;
$restricted = array( __('Posts'));
end ($menu);
while (prev($menu))
{
$value = explode(' ',$menu[key($menu)][0]);
if(in_array($value[0] != NULL?$value[0]:"" , $restricted))
{
unset($menu[key($menu)]);
}
}
}
add_action('admin_menu', 'remove_menus');
get_post_type_objectは、作業を行います。
add_action( 'init', 'ns_change_post_object' );
// Change dashboard Posts to News
function ns_change_post_object() {
$get_post_type = get_post_type_object('post');
$labels = $get_post_type->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';
$labels->all_items = 'All News';
$labels->menu_name = 'News';
$labels->name_admin_bar = 'News';
}