Remove Line Breaks from List Elements in Wordpress
November 2nd, 2009
Posted in: Web Development
Ok, so for some reason, Wordpress insists on outputting cleanly-formatted code (with tabs, line breaks, and everything). The problem I have, is that with this site where the navigation area is an inline-list, these line breaks are translated into spaces between the elements. Combine this with the background hover effect on the elements, and you get a bunch of buttons with spaces between content and right border.
I end up having to tweak this every time I update the site, and compounding this is the fact that between updates, I consistently forget exactly how to do it. Anyways, here’s how:
- Open up wp-includes/classes.php.
- Find the Walker_Page class.
- Find the end_el function of the Walker_Page class.
- Change remove the \n from $output .= “</li>\n”;.
- Save and upload the file.
Yes, I’m aware that this should probably be remedied by creating a custom function in my template that formats the output correctly, but that would require a delving into Wordpress’s class structure that I find much more daunting than just deleting two characters from a file after each update. This fix works on both Wordpress MU, and regular Wordpress.
Permalink