@charset "UTF-8";

/*!
Theme Name: Cocoon Child
Description: Cocoon専用の子テーマ
Theme URI: https://wp-cocoon.com/
Author: わいひら
Author URI: https://nelog.jp/
Template:   cocoon-master
Version:    1.1.3
*/

/************************************
** 子テーマ用のスタイルを書く
************************************/
/*必要ならばここにコードを書く*/

/************************************
** レスポンシブデザイン用のメディアクエリ
************************************/
/*1023px以下*/
@media screen and (max-width: 1023px){
  /*必要ならばここにコードを書く*/
}

/*834px以下*/
@media screen and (max-width: 834px){
  /*必要ならばここにコードを書く*/
}

/*480px以下*/
@media screen and (max-width: 480px){
  /*必要ならばここにコードを書く*/
}
add_filter('wp_nav_menu_items', function($items, $args) {

    if ($args->theme_location === 'navi_header_mobile') {

        $menu_items = wp_get_nav_menu_items($args->menu->term_id);

        foreach ($menu_items as $item) {

            if ($item->object == 'category') {

                $cat = get_category($item->object_id);

                if ($cat) {
                    $items = str_replace(
                        $item->title,
                        $item->title . ' (' . $cat->count . ')',
                        $items
                    );
                }
            }
        }
    }

    return $items;

}, 10, 2);