how to add a style class to wp_list_pages last item
-
Hi there
I need to add a style class item to the last wp_list_pages item
I managed to add a style class for a selected item in the list like as below:
`extract($args, EXTR_SKIP);
$css_class = ‘page_item page-item-‘.$page->ID;
if ( !empty($current_page) ) {
$_current_page = get_page( $current_page );
if ( in_array($page->ID, (array) $_current_page->ancestors) )
$css_class .= ‘ current_page_ancestor’;
if ( $page->ID == $current_page )
$css_class .= ‘ active’; <- i changed this to active
elseif ( $_current_page && $page->ID == $_current_page->post_parent )
$css_class .= ‘ current_page_parent’;
}`However i dont know how to add it to last item. it should render html as follows
-
<li class=”page_item page-item-2 active“>Page 1
<li class=”page_item page-item-3″>Page 2
<li class=”page_item page-item-4″>Page 3
<li class=”page_item page-item-5 last“>Page 4So i dont know where in the wp code to add ‘last’
I would be grateful for any help
Thank you.
Jim
- The topic ‘how to add a style class to wp_list_pages last item’ is closed to new replies.