Return to Snippet

Revision: 23468
at February 8, 2010 10:42 by hstothard


Initial Code
----------------------------------------------
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'));?>

Initial URL

                                

Initial Description

                                

Initial Title
Wordpress - Last class on category navigation

Initial Tags
wordpress

Initial Language
PHP