woocommerce_maybe_show_product_subcategories( string $loop_html = '' )
Maybe display categories before, or instead of, a product loop.
Description Description
Parameters Parameters
- $loop_html
-
(Optional) HTML.
Default value: ''
Return Return
(string)
Source Source
File: includes/wc-template-functions.php
function woocommerce_maybe_show_product_subcategories( $loop_html = '' ) { if ( wc_get_loop_prop( 'is_shortcode' ) && ! WC_Template_Loader::in_content_filter() ) { return $loop_html; } $display_type = woocommerce_get_loop_display_mode(); // If displaying categories, append to the loop. if ( 'subcategories' === $display_type || 'both' === $display_type ) { ob_start(); woocommerce_output_product_categories( array( 'parent_id' => is_product_category() ? get_queried_object_id() : 0, ) ); $loop_html .= ob_get_clean(); if ( 'subcategories' === $display_type ) { wc_set_loop_prop( 'total', 0 ); // This removes pagination and products from display for themes not using wc_get_loop_prop in their product loops. @todo Remove in future major version. global $wp_query; if ( $wp_query->is_main_query() ) { $wp_query->post_count = 0; $wp_query->max_num_pages = 0; } } } return $loop_html; }
Changelog Changelog
Version | Description |
---|---|
3.3.0 | Introduced. |