WordPress 3 Menus

This week I found myself in need of upgrading a WordPress theme I was working on from the old “list_pages” style of menus to the newer, WordPress 3.0 custom menus. I ran into the problem of a serious lack of documentation, not for the new menus themselves, but what to actually change in order to make the upgrade possible.

Luckily, I figured it out. Starting from here, which is a fairly well written tutorial on what the new code is, and working backwards from the theme I was working with, I was able to piece together the specifics. I figured I’d share, just on the off chance someone might find this useful.

First step is to take a look at the theme you’re using, or planning to use and get familiar with how and where the current menu is being called from. Since we’ll be replacing it shortly, it’s probably handy to know where to start.

In this example, I’m using the theme Twicet by Kriesi which I purchased from ThemeForest a while back and has yet to be upgraded by the author.

The first thing we’ll be changing is the functions.php file. Some themes call multiple functions files and may even be in separate directories. So you’ll have to find your primary one and make the changes there.

Since the new WP3 style menus are a completely new function, we have to add it and register it, so that WordPress knows what to do with it.

In your functions.php file, add the following:

add_action( 'init', 'register_my_menu' );

function register_my_menu() {

register_nav_menu( 'primary-menu', __( 'Primary Menu' ) ); }

Now that’s we’ve added the function, we might as well do something with it. In your WordPress 3 dashboard, under ‘Appearance’, there should now be a new link called “Menus”. If your previous theme didn’t support dynamic menus, this option would have been hidden. Since we just added the function to our function.php, it’s now visible!

Feel free to experiment with it and get used to it. It’s probably best to add a couple pages/links to your menu so that after we complete the next step, something will actually appear on your site. If you haven’t made a menu and you continue on, you won’t see anything until you do.

Next we’ll replace the old method of listing pages in your navigation with the new one. Normally this can be found in your header.php file. You’re looking for a line that reads something along the lines of…

<?php wp_list_pages( );   ?>

That’s the old way of listing pages in a navigation, it was literally a “list” of the pages, in order, with some styling applied.

Replace that line with the following:

<?php wp_nav_menu(); ?>

This is the most basic call of the function. You can read more about adding additional menus (if your theme uses more than one) and what’s required for that by reading the tutorial I had mentioned at the top of this post.

So, now we’ve added the function AND called the function into action. We may as well make it look like something.

In my theme I knew I needed to style the menus in a certain way. I added two divs around it, one as a wrapper, in order to get the effect I was looking for. Each div is then styled in my CSS, which I’ll get to in a second. From here on out, these examples apply to the Twicet theme I had mentioned before, but the principles can be applied just about anywhere.

So, in my header, my code looks like this:

<div class="navwrap">
<ul id="menu">
<?php wp_nav_menu(); ?>
</div>

I have the “navwrap” div, then a “menu” div, then my menu.

The “navwrap” serves to display the background image for my menu, and the “menu” div is the text styling of the links themselves.

Also, since my theme uses two separate CSS files, I had to adjust both of them.

My first CSS file, style.css, is used primarily for positioning. My second file, style5.css is used for colors and text styles.

style.css

.navwrap{
font-size:12px;
height:50px;
right: 5px;
line-height:50px;
padding-right:18px;
position:absolute;
top:32px;
z-index:6;
}

.menu{
float:left;
height:50px;
line-height:50px;
padding-left:13px;
}

.menu ul{
margin:0;
padding:0;
list-style-type:none;
list-style-position:outside;
position:relative;
line-height:50px;
z-index:5;
list-style-image: none;
}

.menu a{
height:33px;
display:block;
padding:0 21px;
text-decoration:none;
text-align:center;
line-height:28px;
outline:none;
z-index:35;
position:relative;
float:left;
}

.menu li:hover ul ul, .menu li:hover ul ul ul,.menu li:hover ul ul ul ul{
display:none;
}

.menu li:hover ul, .menu li li:hover ul, .menu li li li:hover ul{
display:block;
}

That basically tells both the “navwrap” and the “menu” where to be, but doesn’t really style the text any. At this point the menu is mostly likely just basic text with bullets. Make sure you add the following if they’re showing up as a bullet-list:

#menu li{ list-style-type:none; list-style-image: none; }
#menu ul{ list-style-type:none; list-style-image: none; }

Now we need to style the text of the menu. Since “menu” is the name of the div I’ve put everything inside of, it’s what I’ll be styling. If you marked it as something different, use the appropriate class names.

In my style5.css, I have the following:

/*navigation*/
.navwrap{
background:transparent url(../images5/menu.png) no-repeat scroll right bottom;
}
.menu a{
color: #9f9f9f;
}
.menu ul {
border:1px solid #DFDFDF;
border-top:none;
}
.menu li ul a{
border-bottom:1px solid #fff;
border-top:1px solid #DFDFDF;
}
.menu ul a, .menu ul li{
background-color:#fff;
background-image:none;
}
.menu ul a:hover, .menu ul a:focus {
background-color: #3b5987;
color:#fff;
}
.menu a:hover, .menu a:focus {
color: #fff;
}
.menu{
background:transparent url(../images5/menu.png) left top no-repeat;
}

The background images might not be specific to your needs, but for me, I have one long menu image, cut into two piece, and using the “left top” and “right bottom” CSS tricks, I’m able to display both sides of it to make a complete menu. This is the reason I have two divs in my header instead of just one.

So, in the end, it’s really pretty easy to upgrade your menus to the new system. There’s just a couple steps:

  1. Add the new functions to functions.php
  2. Change list_pages to the new nav_menu tag in your header.php
  3. Enclose your new menu with a basic div
  4. Update style.css with new styles for your new menu div

That’s it. Good luck with your upgrade!

Winter Forecast

So, in similar fashion to my “Summer Drought” posts, I always like to look forward to the winter gaming season and it’s usual gluttony of triple-A titles. Sure, Christmas is the most common reason given for launching major titles during Q4, but what would the reason be for Q1, Jan-Feb launches? Perceived lack of competition? Hardly. With this number of games, developers will be lucky for even a small piece of the pie.

Whatever the reason, the results are the same. Three to four months of non-stop game releases followed by nothing except the empty void of another summer and the occasional news about next years games. Let the gaming season begin, and let’s have a round up!

As always, this is hardly an exhaustive and complete list. This list really only covers my tastes and the bit of gray areas in between. If you want news on the latest Sims expansion, you’ve come to the wrong place. Also, these are in no particular order. First up…

Bulletstorm – Since Epic has pretty much given up on Unreal Tournament and focused mainly on their Gears of War franchise, a huge void has formed leaving gamers without hours of mindless shooting. The game equivalent of The Expendables, Bulletstorm, according to their own website “delivers a blood symphony of incredible gunplay and carnage on an Epic scale”. You had me at “blood symphony”. I’m not expecting anything with even a thin narrative, but if the gameplay is half of what’s promised, this could be interesting.

Release: Q1/Feb 2011
Interest Level: Medium

Crysis 2 – Given that 97% of the population was completely incapable of actually running it’s predecessor, I’m interested to see exactly where Crytek is headed with this one. FarCry 2 was a beautiful example of a more scalable game engine where-as Crysis was a system killer. If their latest engine (CryEngine 3) is capable of scaling to the Xbox 360 and PS3 as well as high-end gaming machines, I have every reason to believe it might actually run on a mid-level PC as well. I have total faith in their visual quality and graphics, gameplay however is where it all falls apart for Crytek. Somehow, even with arguably the best game engine on the market, most of their games are forgettable and bland. Time will tell if this is game of the year material, or just another benchmarking tool for graphics enthusiasts.

Release: Q1/March 2011
Interest Level: Waiting for Reviews

Star Wars: The Old Republic – Now, right off the bat, I have to admit that I’m not a huge Star Wars guy. I appreciate the finer qualities of the franchise, but the idea of playing a MMO in that universe is both intriguing as well as infuriating. How many terrible MMORPGs have we suffered through in the SW universe? Two, three? I’ve lost count. They don’t work and I’ll tell you why. Nothing, and I mean nothing, is going to live up to a Star Wars nerd’s expectations of being able to “explore” that universe. The thing about MMOs is that not everyone gets to be Luke or Boba Fett. Someone’s got to be the shop keeper. Someone has to be the swamp-rat trader. Someone has to be the droid repair man. Let’s face it, those jobs suck. Now, those lowered expectations aside, the material, movies and screenshots being shown so far do have quite a bit of promise. They might actually pull this off. The promo trailers have been incredible. Since I don’t play MMOs and I refuse to pay for video games as a “service”, I won’t be checking this out. However, this may actually be the MMO that Star Wars fans have been waiting for.

Release: Q1 2011
Interest Level: Zero

Deus Ex: Human Revolution – Now here’s an interesting concept, another trip into the world of Deus Ex, which I really enjoyed the first two times around, but this time with less RPG, more action and a healthy dose of other sci-fi elements thrown in for good measure. I would have been equally interested in simply a well done sequel but it seems they’ve decided to take it up a notch this time. We’ll have to wait until we see some gameplay rather that the (awesome) pre-rendered CG sequences, but if punching through a wall in order to snap someone’s neck is something I actually get to do, sign me up right now. I’m thinking kinda a Jack Bauer meets iRobot meets Blade Runner thing, and I’m ok with that.

Release: Q1 2011
Interest Level: High

Rage – Hmmm, I don’t actually know where to begin with this. John Carmack is without a doubt, a technical genius. He probably has the MENSA membership card to prove it. The last installment of the Carmack legacy, Rage is, for once, not based on demons from hell or bases on Mars. This one is post-apocalyptic desert. Apparently Earth gets hit by a meteor and the people that aren’t dead instantly go all Mad-Max until at some point they decide they miss NASCAR and start racing each other to death. I have, in similar fashion to Crysis 2, no doubts that this will be a game that is graphically superior to most. So much so that apparently Carmack showcased it this past week running on a PC, a 360 AND an iPhone. I wish I was making that last part up. I am not. What I’m more concerned about is if this is another Doom 3. A game so graphically awesome that it forgot where it had come from, and turned out to be a snooze fest.

Release: Jan 7th, 2011
Interest Level: Mild

Civilization 5 – It’s almost too exciting to talk about. A new Civilization descends from the gaming gods in a little over a month. What do you really say when, as a crack addict, someone offers you even better crack? Thank you? I think. Civ 5 is one of those games that, regardless of your preference for the genre, you buy. No other game, and I’ve played my fair share, has caused me to so often look up at the clock and say “holy crap, it’s 3am”. I believe the common meme now is simply “One More Turn”. I’m going to have to find that on a t-shirt somewhere. Anyway, besides the mandatory purchase requirement, it does look to offer some significant upgrades. Graphics, engine, even basic movement have been upgraded. Now the game is going to utilize a 8-sided octagon grid rather than squares. This should really make troop movements interesting. The real question is, does it have Nimoy?

Release: Sept 21, 2010
Interest Level: Already pre-ordered

Call of Duty: Black Ops – I’ve tried twice now to enjoy the COD games made by Treyarch. I simply can’t do it anymore. There was next to nothing redeeming in World At War with the exception of CTF and Zombies. I played 100x more Zombie survival mode than I played actual World At War multiplayer. I think most other people did too. The final straw was the 1200MS point map-packs. For both WaW and MW2, that’s simply too much. If this was Infinity Ward and not Treyarch, I might be interested, but neither the Cold War/Vietname era nor the lack of development time really peak my interest on this one. Given that IW has removed themselves from the Activision situation and that this may very well be the last COD game we see for a while, I think it’s safe to say “the King is dead, long live the King”. It was fun while it lasted fellas.

Release: Nov 2010
Interest Level: Negative

Medal of Honor – Talk about night and day. We go from Call of Duty strait into Medal of Honor, geez, who’s putting together this list? Oh yeah… Well, as one empire falls, another arises. I played the beta, I’ve seen the videos, I don’t really have any doubts anymore that Medal of Honor will be taking the console FPS crown this winter. With multiplayer done by DICE and in a decidedly Battlefield like fashion, and with a solid and convincing modern day story, if modern warfare is at all your cup of tea, this is what we’ll be serving up this winter. I don’t really know what else to say about it besides that it will also include early beta access to the (probably) far off Battlefield 3. That true magnum opus won’t land at least until Q4 2011 or 2012, but I’m considering MoH to be a significant warm-up in the meantime.

Release: Oct 12, 2010
Interest Level: High

Enslaved – Now here’s an interesting one. Original IP action-adventure set in a sci-fi future where jungle has overtaken the urban areas and machines have taken over us. As one Joystiq commenter put it, “the girl from Heavenly Sword and a generic tough guy fight the bad guys from Too Human in the jungle from Uncharted.” Basically, umm, yeah. Not that that’s a bad thing. The world looks bright and colorful, the game play looks reminiscent of Prince of Persia with a little Ratchet and Clank thrown in. I don’t often go for the platformers, but this actually seems to have potential. While it’s not an instant pre-order, I’m certainly keeping an eye on it and I’m interested to see what the reviews turn out to be. Could be a good Amazon Goldbox pick up later on.

Release: Oct 5, 2010
Interest Level: Medium

Fable 3 – I was a sucker for Fable 1, I really enjoyed it. Fable 2 I finished but was barely interested in by the time I did. If I remember correctly, I was more interested in collecting random pieces of bizarre clothing and weird weapons by the end than I was in the actual story in the game. Fable suffers from the problem of almost having too much stuff to do. If I wanted to, I could have stayed in one general area, played cards, had children and the game would have become a wacky British version of the Sims. Unfortunately for the franchise, I’m less and less impressed with “interaction” with random towns-people, and what color I can dye my underwear than I am with good game play. I don’t really care what sort of consequence-based system they’ve created. I don’t really care if my character gets a halo or a set of horns. I want a good, action filled dungeon crawl with lots of junk to collect and stuff to do. If they deliver more of that, I’ll be back for the 3rd installment. If they give me only a weak graphical upgrade and more fart noises to annoy the villages with, I’m afraid I’ll have to pass.

Release: Oct 26th, 2010
Interest Level: Undecided (50/50)

Brink – Brink and Bulletstorm (which I mentioned earlier) are actually going after the same audience. Both are nearly pure action-shooters with hardly any plot worth mentioning. Bulletstorm has Epic going for it which includes their engine and history of blowing shit up. Brink has a different but familiar angle. Customization and gameplay. From the dev-diary videos I’ve seen, you can pretty much create any character type/style/appearance you want. Everything from big bruisers with machine guns to nimble ninjas with blades. It’s also featuring a change in gameplay that they’re touting as interactive and adaptive. Using a single button you character interacts with the environment depending on how and what you’re looking at. Approach a railing, look up and hit the button and you vault over it. Look down and hit the button and you slide under it. That’s probably the simplest example, but you get the idea. Press a magic button and different things happen. Apparently early testers say it really works. I’d love to see a demo and give it a try before committing, but I’m actually pretty interested in Brink, perhaps even more so than Bulletstorm. It’ll probably come down to cost, reviews, and friends possibly playing one or the other for me to make a judgment call between the two. Brink hits earlier than Bulletstorm, so that may be the deciding factor right there.

Release: Sept/Oct 2010 (conflicting reports)
Interest Level: Medium

Torchlight 2 – I have to say that Torchlight was a great and unexpected surprise. Pure, old-school hack’n’slash dungeon crawling fun. I loved it. It was simple, strait forward, didn’t screw around. It had some inventory issues (as most dungeon games do, you’d think someone would have fixed that by now) but was very enjoyable. When I found out that they were making a second, I was thrilled, especially since I’m still waiting on Diablo 3. That’s two short, but complete games from these guys in the time it’s taken Blizzard to even put out a press release about Diablo 3. Note to Blizzard, with stuff this good, I’m not going to wait much longer. Oh, and it’s got Co-op. Awesome.

Release: Q1/Spring 2011
Interest Level: High

Halo: Reach – No. Please stop. Just stop. You’ve already beaten the franchise into the ground. Why continue? Listen, Halo gameplay was NEVER revolutionary, it wasn’t, get over it. The levels, enemies, themes, stories, locations, vehicles, everything is repetitive. Now, after a decade of literally the same thing, you’re going back and trying to give us a story. Sorry, I don’t by it. Epic fail, from all directions.

Release: I don’t care (Sept 14th)
Interest Level: Non-existant

Dead Rising 2 -Being a huge fan of most things zombie related, this is definitely peaking my interest. Unfortunately, it also being produced by Capcom lowers that interest quite a bit. DR1 had some significant issues, mostly the lack of saving ability, it’s horribly translated dialog and tiny, microscopic, unreadable on-screen text. Unless you had a 64″ TV, it was pretty much just dots in the corner of the screen. The downside was that the contents of the text was actually important. At one point, if you didn’t read the text, and didn’t follow it’s directions, a character died. If that character died, the story continued, but you lost the “good” ending to the game. Only thing was, you never knew about it. Huge problem. As for DR2, we move venues from a Mall to the (fake) Vegas strip. You still kill zombies with every object known to mankind, the mechanics look identical, the graphics look improved, and that’s about it. It could be fun, but it definitely isn’t Shakespeare.

Release: Sept 14th, 2010
Interest Level: Medium, but waiting for it on-sale

Dead Space 2 – I admit, I haven’t actually played the first one. Lots of people gave it their “Game of the Year” vote last year. I’m just not especially into the horron genre. However, the sequal is getting enough attention, and I’ve seen enough video to be somewhat interested. I do like sci-fi, I do like shooters, and this looks like it has a few things going for it. I see it as almost a System Shock at this point, and nothing has been able to take the “Creepiest SciFi Game” award away from System Shock 2 yet. This may come close. The first one is on sale all over the place, I plan on picking it up and giving it a try. If I dig it, this will be a purchase for sure.

Release: Jan 2011
Interest Level: Medium

Ghost Recon: Future Soldier – Now, if you want the exact opposite of Call of Duty, you’ve got Ghost Recon. Tom Clancy’s mega-opus about elite soldiers in the near future. This is one of the few franchises left that hasn’t sold out to the 12-year old Halo kiddies yet. This is war, grown-up style. Sneaky, silent, invisibility cloaked sniper war. It really depends on how much MoH I end up playing, but this could be my perfect stand in for Battlefield 3. This is the strategic, modern warfare type game I really enjoy. Plus, if you’re confident enough in your IP to make a live action short out of it, you know they’ve got a lot riding on this. I’m sold.

Release: March 2011
Interest Level: High

That wraps up what I had on my radar. I’ve left out some major titles that are also launching in the same time table, but just didn’t strike my fancy. I also left out some titles like Portal 2, Battlefield 3 and Diablo 3, since the details on those are fuzzy and this was really more focused on this winter. I’m sure I’ll be mentioning those when the time comes.

Also, I had planned on linking to some videos and news stories, but I’m currently writing this off-line, so you’ll have to pardon the lack of related media and rely on Skynet Google to find them for you.

Matt out.

Caffeine Receptacles

So, yeah, my wife is awesome. Two great new coffee mugs in under a week. One artsy, one geeky. Both displayed proudly on my desk at work. No one gets them and I don’t give a shit, lol. They rock.

aperturemug

mycuppacoffee