Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress

Jake Bolton
Jake Bolton
1,956 Points

Can you add customisation options to wordpress menu items?

I've added s nav to a wordpress site and I was wondering if it's possible to add a feature to change the background colour of individual menu items.

Not sure if you can do this, or does it involve the walker class?

Hope you can help.

Many thanks in advance. Jake

6 Answers

Hi Jake,

You could do this using classes on the individual list items.

It may not show right away but if you go to Appearance > Menus you should have an option in the top right for Screen Options.

Drop this down and you'll see CSS Classes with a checkbox next to it.

Tick that and the option to add a class should appear if you click the arrow next to each list item to expand it.

You will then be able to apply a class and style each menu item appropriately.

Thanks

-Rich

Jake Bolton
Jake Bolton
1,956 Points

Hi Guys,

I've managed to resolve this. I didn't used the customizer.php

In the end I used a custom post type and called in a repeater element to the template.

In the end this was the most straightforward way. However I think I'll definitely be interested in the course related to the customizer.php

Many thanks, Jake

Glad you got it sorted :)

-Rich

Jake Bolton
Jake Bolton
1,956 Points

Hi Rich,

Thanks for pointing that out, I've never seen that before.

The only thing is that as I'm developing a theme that the client wants to be able to customise, therefore I was hoping to add a function the the customizer.php so that the client can just choose the colour of the link background.

I don't know if you have seen anything like this.

Having a real nightmare finding anything I can follow on the codex.

Thanks for your help.

Cheers, Jake

I haven't had to do that myself yet so can't advise I'm afraid.

Hope you get it sorted though :)

-Rich

Jake Bolton
Jake Bolton
1,956 Points

No worries.

Thanks for your insights Rich.

Cheers, jake

Zac Gordon
STAFF
Zac Gordon
Treehouse Guest Teacher

We have a course coming out on the Customizer API that will help you implement the ability to let the client customize the colors. Have you been able to get the basic functionality working yet?

Jake Bolton
Jake Bolton
1,956 Points

Hi Zac,

I've used the customizer.php to apply global styles to the HTML, I haven't yet managed to to add custom styling to individual <li> tags that Wordpress outputs.

The fact that the end client needs to be able to customise the background makes this a bit more difficult.

I'll look out for the course you mentioned, I'll have to go through the codex and see if I can dig anything up.

Cheers, Jake