page_css_class

Filters the list of CSS classes to include with each page item in the list.

Description

apply_filters( 'page_css_class', (array) $css_class, (WP_Post) $page, (int) $depth, (array) $args, (int) $current_page ); 

Parameters (5)

0. $css_class (array)
An array of CSS classes to be applied to each list item.
1. $page (WP_Post)
Page data object.
2. $depth (int)
Depth of page, used for padding.
3. $args (array)
An array of arguments.
4. $current_page (int)
ID of the current page.

Usage

To run the hook, copy the example below.
  1. $css_class = apply_filters( 'page_css_class', $css_class, $page, $depth, $args, $current_page ); 
  2.  
  3. if ( !empty( $css_class ) ) { 
  4.  
  5. // everything has led up to this point... 
  6.  
  7.  
The following example is for adding a hook callback.
  1. // define the page_css_class callback 
  2. function filter_page_css_class( $css_class, $page, $depth, $args, $current_page ) { 
  3. // make filter magic happen here... 
  4. return $css_class
  5. }; 
  6.  
  7. // add the filter 
  8. add_filter( 'page_css_class', 'filter_page_css_class', 10, 5 ); 
To remove a hook callback, use the example below.
  1. // remove the filter 
  2. remove_filter( 'page_css_class', 'filter_page_css_class', 10, 5 ); 

Defined (1)

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

/wp-includes/class-walker-page.php  
  1. $css_classes = implode( ' ', apply_filters( 'page_css_class', $css_class, $page, $depth, $args, $current_page ) );