I have several menus generated on a page using wp_list_pages. I want to add a class to the last menu item on only one instance of these.
For example, I have a menu here:
<ul id="headerlinks">
<?php wp_list_pages('title_li=&include=24,26,28,30'); ?>
</ul>
And another like so:
<ul id="sublinks">
<?php wp_list_pages('title_li=&include=4,6,8,10,12,14,20,22'); ?>
</ul>
In my functions.php file I am using the following to add classes to the first and last menu items of wp_list_pages:
// Adds classes to first and last item in list of wp_list_pages
function add_markup_pages($output) {
$output= preg_replace('/page_item/', ' first-page-item page-item', $output, 1);
$output=substr_replace($output, " last-page-item page_item", strripos($output, "page_item"), strlen("page_item"));
return $output;
}
add_filter('wp_list_pages', 'add_markup_pages');
However, I only want to have this applied to the #headerlinks menu. How can I target it using the function above?