Filter hook 'page_css_class'

in WP Core File wp-includes/class-walker-page.php at line 159

View Source

page_css_class

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

Hook Information

File Location wp-includes/class-walker-page.php View on GitHub
Hook Type Filter
Line Number 159

Hook Parameters

Type Name Description
string[] $css_class An array of CSS classes to be applied to each list item.
WP_Post $page Page data object.
int $depth Depth of page, used for padding.
array $args An array of arguments.
int $current_page_id ID of the current page.

Usage Examples

Basic Usage
<?php
// Hook into page_css_class
add_filter('page_css_class', 'my_custom_filter', 10, 5);

function my_custom_filter($css_class, $page, $depth, $args, $current_page_id) {
    // Your custom filtering logic here
    return $css_class;
}

Source Code Context

wp-includes/class-walker-page.php:159 - How this hook is used in WordPress core
<?php
 154  		 * @param WP_Post  $page            Page data object.
 155  		 * @param int      $depth           Depth of page, used for padding.
 156  		 * @param array    $args            An array of arguments.
 157  		 * @param int      $current_page_id ID of the current page.
 158  		 */
 159  		$css_classes = implode( ' ', apply_filters( 'page_css_class', $css_class, $page, $depth, $args, $current_page_id ) );
 160  		$css_classes = $css_classes ? ' class="' . esc_attr( $css_classes ) . '"' : '';
 161  
 162  		if ( '' === $page->post_title ) {
 163  			/* translators: %d: ID of a post. */
 164  			$page->post_title = sprintf( __( '#%d (no title)' ), $page->ID );

PHP Documentation

<?php
/**
		 * Filters the list of CSS classes to include with each page item in the list.
		 *
		 * @since 2.8.0
		 *
		 * @see wp_list_pages()
		 *
		 * @param string[] $css_class       An array of CSS classes to be applied to each list item.
		 * @param WP_Post  $page            Page data object.
		 * @param int      $depth           Depth of page, used for padding.
		 * @param array    $args            An array of arguments.
		 * @param int      $current_page_id ID of the current page.
		 */
Quick Info
  • Hook Type: Filter
  • Parameters: 5
  • File: wp-includes/class-walker-page.php
Related Hooks

Related hooks will be displayed here in future updates.