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:
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.
-
Gum Addon for Elementor50,000+ installs
apply_filters( 'page_css_class', $css_class, $page, $depth, $args, $current_page )helper.php:466 -
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 -
WPKoi Templates for Elementor5,000+ installs
apply_filters( 'page_css_class', $css_class, $page, $depth, $args, $current_page )theme/inc/structures.php:574 -
List Pages Shortcode5,000+ installs
apply_filters( 'page_css_class', $css_class, $page, $depth, $args, $current_page )list-pages-shortcode.php:344 -
EazyDocs2,000+ installs
apply_filters( 'page_css_class', $css_class, $page, $depth, $args, $current_page )includes/Frontend/Walker_Docs.php:164 -
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 -
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 -
Documentation100+ installs
apply_filters( 'page_css_class', $css_class, $page, $depth, $args, $current_page )lib/views/class-documentation-walker-document.php:117 -
Ambrosite Unlink Parent Pages60+ installs
apply_filters( 'page_css_class', $css_class, $page )ambrosite-unlink-parent-pages.php:131 -
SF Bootstrap Menu10+ installs
apply_filters( 'page_css_class', $css_class, $page, $depth, $args, $current_page )sf-navwalker-horizontal.php:106 -
Role Based Help Notes10+ installs
apply_filters( 'page_css_class', $css_class, $page, $depth, $args, $current_page )includes/class-walker-editlink.php:55 -
Demo Content Templates10+ installs
apply_filters( 'page_css_class', $css_class, $page, $depth, $args, $current_page )src/Infrastructure/Walker_Page_Checkbox.php:106 -
Tagged Sitemap10+ installs
apply_filters( 'page_css_class', $css_class, $page )functions.php:83 -
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 -
Online Help Sliding MenuFewer than 10 installs
apply_filters( 'page_css_class', $css_class, $page, $depth, $args, $current_page )OHSM_Walker_Pages.php:58 -
Lingenio Translation ServiceFewer than 10 installs
apply_filters( 'page_css_class', $css_class, $page, $depth, $args, $current_page )pg_public/navigation.php:68 -
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.