wc_list_pages

Fix active class in wp_list_pages for shop page.

Description

(string) wc_list_pages( (string) $pages ); 

https://github.com/woocommerce/woocommerce/issues/177.

Returns (string)

Parameters (1)

0. $pages (string)
The pages.

Usage

  1. if ( !function_exists( 'wc_list_pages' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'woocommerce/includes/wc-page-functions.php'; 
  3.  
  4. // The pages. 
  5. $pages = ''; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = wc_list_pages($pages); 
  9.  

Defined (1)

The function is defined in the following location(s).

/includes/wc-page-functions.php  
  1. function wc_list_pages( $pages ) { 
  2. if ( is_woocommerce() ) { 
  3. // Remove current_page_parent class from any item. 
  4. $pages = str_replace( 'current_page_parent', '', $pages ); 
  5. // Find shop_page_id throughwoocommerceoptions. 
  6. $shop_page = 'page-item-' . wc_get_page_id( 'shop' ); 
  7.  
  8. if ( is_shop() ) { 
  9. // Add current_page_item class to shop page. 
  10. $pages = str_replace( $shop_page, $shop_page . ' current_page_item', $pages ); 
  11. } else { 
  12. // Add current_page_parent class to shop page. 
  13. $pages = str_replace( $shop_page, $shop_page . ' current_page_parent', $pages ); 
  14.  
  15. return $pages;