This website uses cookies to remember you and improve your experience. For more info see our Privacy Policy.

  • About
  • Websites
    • Business Websites
    • Author Websites
  • SEO
  • Portfolio
    • Author Web Design
    • Business Web Design
    • Custom Graphics
    • Logos
  • Services & Pricing
    • Author Website Packages
    • Website Hosting
    • Page Speed Optimization
    • SEO
    • Local SEO
  • MyBookTable
    • MyBookTable Support
  • Contact
  • Hire Us

Mobile Menu

  • Menu
  • Skip to right header navigation
  • Skip to main content

Stormhill Media

Custom websites for every type of business

Header Right

  • About
  • Websites
    • Business Websites
    • Author Websites
  • SEO
  • Portfolio
    • Author Web Design
    • Business Web Design
    • Custom Graphics
    • Logos
  • Services & Pricing
    • Author Website Packages
    • Website Hosting
    • Page Speed Optimization
    • SEO
    • Local SEO
  • MyBookTable
    • MyBookTable Support
  • Contact
  • Hire Us

MENU – show class in wp_list_pages for links that have kids

Home » Code Snippets » MENU – show class in wp_list_pages for links that have kids

This comes in handy if you are using a list_page menu and need to change the style of menu elements that have children, liks add an arrow. This needs to be in the functions file.

add_filter('page_css_class', 'nice_navigation_page_css_class', 10, 2);
/**
 * adds class "page-has-children" to all pages that have children
 * @param array $class.    The page css class being modified, passed as an array from Walker_Page
 * @param object $page.    The page object passed from Walker_Page
 * @return array            Returns the new page css class.
 */
function nice_navigation_page_css_class($class, $page) {
 // check if current page has children
 $children = get_pages('child_of='.$page->ID);
 if (sizeof($children) > 0) {
  $class[] = "page-has-children";
 }
 
 return $class;
}

« Previous
Next »

Site Footer

Quick Links:

  • Contact Us
  • Pricing & Services
  • Sitemap
  • Terms/Conditions
  • Privacy Policy
  • Business Websites
  • Author Websites
  • SEO Services
(903) 213-5266‬

Copyright © 2026 · Stormhill Media All Rights Reserved.
Website by Stormhill Media
Log in