WordPress Developers Share Custom is_child() Function for Advanced Navigation
A developer notes that WordPress lacks a built-in is_child() conditional tag, which advanced theme builders need for sidebar navigation showing the next level of child pages. The article provides a custom function that checks whether the current page's parent matches a given page ID, slug, or title. The function is added to a theme's functions.php file and can be called with any of these identifiers. For deeper page hierarchies, the author suggests an is_ancestor() function that checks the post's ancestors list. A further, untested version checks whether a post is either a child or an ancestor of a specified page ID.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in