tallphil

Taking WordPress Menus back to basics

Tue, 6th Sep, 2011, 17:43:43  |  Category: WordPress

I was working on a project earlier where I was using the wp_nav_menu function in WordPress to create a menu. By default, WordPress creates menus which are wrapped in layers (<div>), an unordered list (<ul>), list items (<li>) and then a link (<a>). However, on this project I wanted to use jQuery UI to generate a navigation, and that required just links (<a> <a> <a>).

So, to strip out all of those extra HTML tags, I used the following javascipt (as I was already relying on jQuery and javascript anyway).

var newmenu = '';
jQuery("#nav ul li").each(function() {
	newmenu += jQuery(this).html();
});
jQuery("#nav").html(newmenu);

This works by firstly looping through all of the list items in my navigation layer, and copying their contents (the menu link) into a variable. Then, I replace all of the HTML contained within my navigation layer with that string. Easy!

Comment on this post

Flickr Press

Tue, 19th Jul, 2011, 23:54:28  |  Category: WordPress, WordPress Plugins

I’ve been using the excellent Flickr Press plugin to display flickr sets on a website that I’ve been working on lately, and I made a few changes to make life easier. In case anyone else may find them useful, I’ve uploaded the modified plugin here for general use. I’ve notified the original author, so hopefully if he likes the changes they may be pushed in a future update. For now you can download it here.

Continue reading

Comment on this post

Flickr Badge

Fri, 8th Jul, 2011, 14:56:43  |  Category: WordPress, WordPress Plugins

I’ve been using the excellent flickr badge on a website lately, and decided that it would be nice to put the script in as a widget, with easy to update options to customise it. So, I wrote a quick plugin which does just that…

Continue reading

Comment on this post