WordPress filter hook · part of WordPress core

page_css_class

A WordPress core filter that 17 plugins also fire themselves, running on 73K+ sites between them.

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

How to use page_css_class

It's a filter: your callback receives the value and 4 more arguments, and must return the (changed) value. Add this to your theme's functions.php or a small custom plugin:

functions.php
add_filter( 'page_css_class', function( $css_class, $page, $depth, $args, $current_page ) {
	// Change $css_class here.
	return $css_class;
}, 10, 5 );

Argument names come from Gum Addon for Elementor's source. Other plugins may pass different values: check the call in the plugin you're targeting below.

This hook is fired by WordPress core too. Official reference on developer.wordpress.org →

17 plugins that fire page_css_class

Sorted by active installs. Each entry shows where the plugin calls the hook and what it passes.

  1. Gum Addon for Elementor icon Gum Addon for Elementor50,000+ installs apply_filters( 'page_css_class', $css_class, $page, $depth, $args, $current_page ) helper.php:466
  2. WPB Accordion Menu icon WPB Accordion Menu10,000+ installs apply_filters( 'page_css_class', $css_class, $page, $depth, $args, $current_page_id ) inc/helper/class.posts-walker.php:79
  3. WPKoi Templates for Elementor icon WPKoi Templates for Elementor5,000+ installs apply_filters( 'page_css_class', $css_class, $page, $depth, $args, $current_page ) theme/inc/structures.php:574
  4. List Pages Shortcode icon List Pages Shortcode5,000+ installs apply_filters( 'page_css_class', $css_class, $page, $depth, $args, $current_page ) list-pages-shortcode.php:344
  5. EazyDocs icon EazyDocs2,000+ installs apply_filters( 'page_css_class', $css_class, $page, $depth, $args, $current_page ) includes/Frontend/Walker_Docs.php:164
  6. Waka Bulk Page icon Waka Bulk Page1,000+ installs apply_filters( 'page_css_class', $css_class, $page, $depth, $args, $current_page ) includes/class-waka-bulk-page-walker.php:126
  7. BU Navigation icon BU Navigation100+ installs apply_filters( 'page_css_class', $item_classes, $page, 0, array(), (int) $page->ID ) composer-includes/bu-navigation-core-widget/src/data-format.php:320
  8. Documentation icon Documentation100+ installs apply_filters( 'page_css_class', $css_class, $page, $depth, $args, $current_page ) lib/views/class-documentation-walker-document.php:117
  9. Ambrosite Unlink Parent Pages icon Ambrosite Unlink Parent Pages60+ installs apply_filters( 'page_css_class', $css_class, $page ) ambrosite-unlink-parent-pages.php:131
  10. SF Bootstrap Menu icon SF Bootstrap Menu10+ installs apply_filters( 'page_css_class', $css_class, $page, $depth, $args, $current_page ) sf-navwalker-horizontal.php:106
  11. Role Based Help Notes icon Role Based Help Notes10+ installs apply_filters( 'page_css_class', $css_class, $page, $depth, $args, $current_page ) includes/class-walker-editlink.php:55
  12. Demo Content Templates icon Demo Content Templates10+ installs apply_filters( 'page_css_class', $css_class, $page, $depth, $args, $current_page ) src/Infrastructure/Walker_Page_Checkbox.php:106
  13. Tagged Sitemap icon Tagged Sitemap10+ installs apply_filters( 'page_css_class', $css_class, $page ) functions.php:83
  14. BU Learning Blocks icon BU Learning Blocks10+ installs apply_filters( 'page_css_class', $item_classes, $page, 0, array(), (int) $page->ID ) inc/bu-navigation-core-widget/src/data-format.php:320
  15. Online Help Sliding Menu icon Online Help Sliding MenuFewer than 10 installs apply_filters( 'page_css_class', $css_class, $page, $depth, $args, $current_page ) OHSM_Walker_Pages.php:58
  16. Lingenio Translation Service icon Lingenio Translation ServiceFewer than 10 installs apply_filters( 'page_css_class', $css_class, $page, $depth, $args, $current_page ) pg_public/navigation.php:68
  17. VIT Sitemap icon VIT SitemapFewer than 10 installs apply_filters( 'page_css_class', $css_class, $page, $depth, $args, $current_page ) includes/sitemap_Main.php:233

Need a customisation built on this hook?

Tell us what you want to change and which plugin it's for. We'll write it, test it and send it back as a small plugin.