/ Published in: PHP

Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
---------------------------------------------- Functions.php ---------------------------------------------- function add_last_class($input) { if( !empty($input) ) { $pattern = '/<li class="(?!.*<li class=")/is'; $replacement = '<li class="last '; $input = preg_replace($pattern, $replacement, $input); echo $input; } } ---------------------------------------------- Header.php Need to put echo=0 for it to work when calling this function ---------------------------------------------- <?php add_last_class(wp_list_categories('title_li=&echo=0'));?>
Comments
