WC_Breadcrumb::add_crumbs_categoryprotectedWC 1.0

Category trail.

Method of the class: WC_Breadcrumb{}

No Hooks.

Returns

null. Nothing (null).

Usage

// protected - for code of main (parent) or child class
$result = $this->add_crumbs_category();

WC_Breadcrumb::add_crumbs_category() code WC 10.8.1

protected function add_crumbs_category() {
	$this_category = get_category( $GLOBALS['wp_query']->get_queried_object() );

	if ( is_wp_error( $this_category ) || ! $this_category ) {
		return;
	}

	if ( 0 !== intval( $this_category->parent ) ) {
		$this->term_ancestors( $this_category->term_id, 'category' );
	}

	$this->add_crumb( single_cat_title( '', false ), get_category_link( $this_category->term_id ) );
}