Q.カスタム投稿タイプ「商品」ページの投稿にアイキャッチを入れたい
特に商品ページを「関連記事カードリンク」で設定したいときにアイキャッチを入れなければサムネイル部分が「No image」となります。
A.下記のphpファイルの該当箇所を編集します
編集するテーマファイル:function.php
before
//カスタム投稿 「商品」を追加 ----------------------------------------------------------------
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')
));
};
↓ after
//カスタム投稿 「商品」を追加 ----------------------------------------------------------------
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','thumbnail') //アイキャッチを追加
));
};
万が一カスタマイズによって不具合が生じても弊社では責任を負いかねますので
カスタマイズに際しては必ずバックアップをご用意の上、
お客様の責任において実施していただきますようお願い申し上げます。
この記事は役に立ちましたか?
もし参考になりましたら、下のボタンで教えてください。
今後の記事作成の参考とさせて頂きます!