Build Your Own Business Website header image

Community Library Website Case Study – Part 36, Add HTML Markup to WordPress Menus

Difficulty Level -

Filed Under Topics - , , ,

Listed Under Lesson Subjects -

Applies to - ,

Whoops, you've found some premium content!

Watch the opening clip of this video to preview it,
the full video is available to paid members.

This is the thirty sixth in a series of live lessons on using WordPress and Thesis as a Content Management System (CMS). In this lesson we continue working on the menus in our new catalog page. We create an HTML structure around the menus to add headings in custom_functions.php and then style the html structure with CSS using Firebug and Web Developer.

Video Transcript

So now we have 2 sets of menus stacked similarly to what Pam had like this. Now we want to have some headings to adults and children. Let’s see, so let’s go ahead to that part of it, adding headings to these menus and we’ll do that in custom functions php.

What we want to do here is we’re going to create an HTML structure around this and so, that is going to look like… it’s going to happen after if is page and we’ll say echo which is sort of a print statement. It’s going to print this stuff that’s in these parentheses, close that off. Now we’re going to echo div class equals and let’s see, byob adult menu. And then we will add a p tag and we’ll type in adult menu…oh no, not adult menu. Just adults and then the closing p tag. Okay so that starts it off and then at the end of this, after we’ve printed our menu, we’re going to echo again and in this echo statement, we’re just going to close the div. And then put our closing semi-colon in and then really, we’re just going to do the exact same thing here with children’s menu. Okay… except that it’s not going to be adult menu, it’ll be children’s menu. And yeah, then we’re just going to close off this div… no, echo.

Okay so now I’ve got the structure for that and we’ve… oh, but we’re not doing adults. We’re doing children. Okay, we’re going to save this, we’re going to upload it and then we’re going to take a look at it.

Okay so now what we need to do is we need to add styling to these 2 divs that we’ve wrapped these in. And so, if we come back down here… let’s see, adult menu, inspect the element… that is byob adult menu and yeah… so we’ll copy that. And we’ll come up here… try that again to adult menu. Give ourselves a space, byob adult menu and we will say… let’s see, let’s float left. Left, okay… that got them back up side by side. And then let’s make this p tag, control copy, adult menu and then we’ll do p. And last time it’s float left, it’s going to be text align center and then we’re going to make the font size big so font size: 24 px. And let’s give it a little bit more space under it so margin bottom: 20 px. Oh that’s too much space, call it 10 px. Yeah, that’s pretty good.

Well so we need to do exactly this same thing for the children’s menu. And it’s going to be children’s and children’s. And then I also want to give myself a little bit more margin here so I’m going to say margin left: 20 px. Yeah, that looks pretty good actually. How does that shape up with our… yeah you know, it looks like it shapes up with that space really well. I could probably move it just a little bit more, maybe 24 pixels. And now we have these 2 different menus and all we have to do is save this stuff. It took all the way to the top, start at the top of the adult menu all the way to the bottom… copy, save that. Replace everything, save it, upload it… let’s check it out.

Okay, it looks great in Firefox. Let’s see how it looks in Chrome, refresh that. Okay, looks good in Chrome. Better check it in Internet Explorer, let’s see. Let’s come over here, have that URL… and you can see that it doesn’t have the… I mean, it works just fine but it doesn’t have the drama in Internet Explorer 8 but Internet Explorer 9 will do the same thing as Firefox and Chrome and Safari. Now you know, it’s not… what you really want is if it doesn’t work, you want it to degrade properly and that’s what we’ve accomplished here, we’ve allowed it to. I mean, it degrades nicely. It still looks good here.

Okay so that wraps up that part.

0 Comments… add one

Save $200 on Membership Now!

Start learning today for as little as
$0.82 PER DAY!
Subscription Options
0 comments… add one