Is this possible? I need to be able to sniff out menu items that have subpages so as to add an indicator graphic next to them.
Seems like this is common functionality.
Is this possible? I need to be able to sniff out menu items that have subpages so as to add an indicator graphic next to them.
Seems like this is common functionality.
body.page-parent
Never mind, question was regarding a CSS class.
EDIT: With get_page_children(), you can get the children of the page you're looking after. Pages with results on this function will have children, zero results will have no children.
But then again;
This is for the parent of the current page, not for a page with childs. Guess the get_page_children() function is needed after all?
Last edited by coenjacobs; 06-07-2010 at 08:15 AM.
Follow me on Twitter: @cnjcbs or via my blog: http://cnjcbs.com
Yes, I have a solution for WYSIWYG widgets: Smart WYSIWYG Blocks Of Content
No. It just means that the current page is a parent page, therefore has child pages.
Mild Fuzz wasn't particularly specific about what they're trying to do though so I'm not sure if that particular class will help or not. It depends on what the context of the problem is.
Sorry!!
What I actually want is a class in the <li> item in the global navigation. Like an pull down arrow or similar. So we will neither necessarily be on the parent or child page, it will need to work on all pages as I intend it to be part of the nav.
I posted a similar question on Twitter recently and did't receive any help.
I ended up writing a rather long winded and kinda borked rewrite of the wp_list_pages() function to do it. There has to be a better way to do it than what I did, so I won't post it here unless nobody else can come up with a more suitable solution.
If you are looking for a parent or ancestor in the hierarchical tree of the current page, you can use the li.current_page_parent and li.current_page_ancestor classes.
It would be nice if the function would return classes like "page_parent" and "page_ancestor" for parents/ancestors outside of the current hierarchical tree, but it doesn't, unfortunately. (Strangely, bbPress *does* return similar classes, it its function that lists forums.)
WP TurnKey - Turn-Key WordPress installation and maintenance services
WordPress user since 2005 | @chip_bennett | chipbennett.net | cbnet Plugins
If you're missing CSS classes and you consider to open a ticket in wordpress trac for it: I opened a ticket regarding improvement of those for widgets where you might want to reference your ticket to as well:
#12615 - Add "first" and "last" CSS-class-names to each Widget in sidebars (Frontend)
hakre on wordpress (clicking this all three minutes help to keep the cache fresh - thanks)
Code:<?php echo ereg_replace( "\"><a [/\?a-zA-Z0-9\-\.\:\"\=\_ >]+</a>([\t\n]+)<ul"," haschildren\\0", wp_list_pages() ); ?>
This is how I do it.
PHP Code:echo preg_replace('/(<li class="page_item+)(.*<\/a>\s)/',
'$1 has_children$2',
wp_list_pages('echo=0'));