「TCD AWARD 2023」受賞サイトを発表しました。

ワードプレステーマ別

TCDテーマPrecious:投稿タイプ「商品」の名前を変更する

Q.カスタム投稿タイプ名「商品」を変更したい

カスタム投稿タイプ「商品(商品紹介ページ)」の投稿タイプ名を変更することはできますか?

A.下記のphpファイルの該当箇所を編集します

編集するファイル:functions.php
編集する箇所:

if ( function_exists('register_post_type') ) {
 $labels = array(
  'name' => __('Product', 'tcd-w'),
  'singular_name' => __('Product', 'tcd-w'),
  'add_new' => __('Add New', 'tcd-w'),
  'add_new_item' => __('Add New Item', 'tcd-w'),
  'edit_item' => __('Edit', 'tcd-w'),
  'new_item' => __('New item', 'tcd-w'),
  'view_item' => __('View Item', 'tcd-w'),
  'search_items' => __('Search Items', 'tcd-w'),
  'not_found' => __('Not Found', 'tcd-w'),
  'not_found_in_trash' => __('Not found in trash', 'tcd-w'), 
  'parent_item_colon' => ''
 );

 register_post_type('product', array(
  'label' => __('Product', 'tcd-w'),
  'labels' => $labels,
  'public' => true,
  'publicly_queryable' => true,
  'menu_position' => 5,
  'show_ui' => true,
  'query_var' => true,
  'rewrite' => array('slug' => 'product'),
  'capability_type' => 'post',
  'has_archive' => true,
  'supports' => array('title','editor','comments')
 ));
};

管理画面のメニュー「商品」を変更したい場合は、’name’ の値を、URL等に表示されるスラッグを変更したい場合は、’rewrite’ の値である配列中の’slug’の値を任意にご変更ください。

なお、上記変更だけでは商品一覧ページの見出しが変更されません。
この部分についてはこちらの記事をご参照ください。

この記事は役に立ちましたか?

もし参考になりましたら、下のボタンで教えてください。
今後の記事作成の参考とさせて頂きます!

同じテーマのカスタマイズ記事