wc_list_pages()
Fix active class in wp_list_pages for shop page.
See details in https://github.com/woocommerce/woocommerce/issues/177.
No Hooks.
Return
String
.
Usage
wc_list_pages( $pages );
- $pages(string) (required)
- Pages list.
wc_list_pages() wc list pages code WC 8.0.2
function wc_list_pages( $pages ) { if ( ! is_woocommerce() ) { return $pages; } // Remove current_page_parent class from any item. $pages = str_replace( 'current_page_parent', '', $pages ); // Find shop_page_id through woocommerce options. $shop_page = 'page-item-' . wc_get_page_id( 'shop' ); if ( is_shop() ) { // Add current_page_item class to shop page. return str_replace( $shop_page, $shop_page . ' current_page_item', $pages ); } // Add current_page_parent class to shop page. return str_replace( $shop_page, $shop_page . ' current_page_parent', $pages ); }