• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
WordPress a2z

WordPress a2z

WordPress Dynamic API Reference

  • Home
  • Plugins
  • Themes
  • Shortcodes
  • APIs
  • Classes
  • Files
  • Hooks
  • Sitemap
  • Blog
Home / APIs / twentytwenty_filter_wp_list_pages_item_classes() – Filters classes of wp_list_pages items to match menu items.

You appear to be a bot. Output may be restricted

Description

Filters classes of wp_list_pages items to match menu items.

Filter the class applied to wp_list_pages() items with children to match the menu class, to simplify. styling of sub levels in the fallback. Only applied if the match_menu_classes argument is set.

Usage

$array = twentytwenty_filter_wp_list_pages_item_classes( $css_class, $page, $depth, $args, $current_page );

Parameters

$css_class
( string[] ) required – An array of CSS classes to be applied to each list item.
$page
( WP_Post ) required – Page data object.
$depth
( int ) required – Depth of page, used for padding.
$args
( array ) required – An array of arguments.
$current_page
( int ) required – ID of the current page.

Returns

array CSS class names.

Source

File name: twentytwenty/inc/template-tags.php
Lines:

1 to 22 of 22
function twentytwenty_filter_wp_list_pages_item_classes( $css_class, $page, $depth, $args, $current_page ) {

  // Only apply to wp_list_pages() calls with match_menu_classes set to true.
  $match_menu_classes = isset( $args['match_menu_classes'] );

  if ( ! $match_menu_classes ) {
    return $css_class;
  }

  // Add current menu item class.
  if ( in_array( 'current_page_item', $css_class, true ) ) {
    $css_class[] = 'current-menu-item';
  }

  // Add menu item has children class.
  if ( in_array( 'page_item_has_children', $css_class, true ) ) {
    $css_class[] = 'menu-item-has-children';
  }

  return $css_class;

}
 

 View on GitHub View on Trac

Published: 25th November 2019 | Last updated: 21st August 2020

Primary Sidebar

Information

Function name: twentytwenty_filter_wp_list_pages_item_classes
Plugin ref: Twenty Twenty
Version: 2.1
Sourcefile: inc/template-tags.php
File ref: inc/template-tags.php
Deprecated?: No
API Letters: F,L,P,T,W

Footer

WordPress a2z
WordPress a2z
WordPress Dynamic API Reference
WordPress 6.1.1. PHP: 8.0.28
WordPress a2z
WordPress core a2z
Genesis Theme Framework a2z
Jetpack a2z
WordPress develop tests
Easy Digital Downloads a2z
WooCommerce a2z
Yoast SEO a2z
WordPress Blocks

Site:  wp-a2z.org
© Copyright WordPress a2z 2014-2023. All rights reserved.


Website designed and developed by Herb Miller
Proudly powered by WordPress and oik plugins

  • Home
  • Blog
  • Sitemap
  • Sites