Support » Fixing WordPress » How can this function be optimised?

  • I’m trying to get to grips with WordPress frameworks (Thematic) and using the functions.php file to make the necessary changes. Here I want to add a list of archives at the top of the is_date pages.

    But I also want shorten the monthly archives to the three letter format, rather than showing the full name of the month. The following code does what it is supposed to, but it wouldn’t work in other languages than English. Is there a better way to do the same thing?

    function add_archives_list ($pagetitle) {
    	if (is_date()) :
    			$archives = wp_get_archives('type=monthly&echo=0');
    			$fullmonths = array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
    			$shortmonths = array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
    
    			$litems = str_replace($fullmonths, $shortmonths, $archives);
    	endif;
    	return '<ul class="archive-list">' . $litems . '</ul>' . $pagetitle;
    }
    add_filter ('thematic_page_title', 'add_archives_list');
  • The topic ‘How can this function be optimised?’ is closed to new replies.