valiable = $args; if ( $this->valiable == 'main' ) { $this->main_category(); } else if ( $this->valiable == 'sub' ) { $this->sub_category(); } } /** * main category */ private function main_category() { $args = array( 'orderby' => 'name', 'parent' => 0, 'pad_counts' => 1 ); echo '
'; $categories = get_categories( $args ); foreach ( $categories as $category ) { if ( $this->count_main ) $this->count_main = $this->str . $category->count . $this->end; echo '' . $category->name . $this->count_main . ''; } echo '
'; } /** * sub category */ private function sub_category() { $args = array( 'parent' => get_query_var('cat'), 'pad_counts' => 1 ); $categories = get_categories( $args ); $is_category = get_queried_object(); if (is_object($is_category)) { $is_flg = $is_category->taxonomy; /** * breadcrumbs */ if ($is_flg === 'category') { echo '
'; echo ''; $cat_array = get_category_parents($is_category->term_id, false, "/", true); $cat_array = explode( "/", $cat_array); foreach ( $cat_array as $key => $value ) { if( $value ){ $cat_by_slug = get_category_by_slug( $value ); if( $this->count_bread ) $this->count_bread = $this->str . $cat_by_slug->count . $this->end; if( $cat_by_slug->cat_ID === $is_category->term_id ) { echo $cat_by_slug->name . $this->count_bread; } else { echo '' . $cat_by_slug->name . $this->count_bread . $this->arrow . ''; } } } echo ''; } /** * category */ if ($categories && $is_flg === 'category') { echo ''; foreach ($categories as $category) { if ( $this->count_sub ) $this->count_sub = $this->str . $category->count . $this->end; echo '' . $category->name . $this->count_sub . ''; } echo ''; } echo '
'; } } } /** * line category css */ function category_css() { $cssPath = plugin_dir_url( __FILE__ ) . 'ataino-line-category.css'; wp_enqueue_style( 'line_category_css', $cssPath, array(), '1.0', 'all' ); } add_action( 'wp_enqueue_scripts', 'category_css' ); ?>