Tag Archives: Tutorial

The Walker_Comment class seems to be the weirdest and most hacked together of all the Walker classes in WordPress. Despite a few hours searching, I could not find a single example of a working Walker_Comment class anywhere on the entire internet. So I made this one from scratch by copying the default Walker_Comment function that comes with WordPress. It’s doing what I need it to, but I’m not 100% sure I’m using it properly.

Weirdness

Ignoring $output

Although the functions are set up to pass a global &$output variable forward, they don’t do it (at least in the default Walker class), they just echo each portion as it comes. It appears the Walker totally ignores the variable which just strikes me as odd.

start_lvl() Isn’t the Start

The start_lvl() function, with a $depth of 0 begins at each child comment, so essentially at the start of every reply which is the first to reach a new level under a particular comment. This took me awhile to figure out and is also rather odd. That’s why you have to wrap the comment list div/ol/ul yourself, because it has no way to reach the top of it’s own comments list.
I was able to wrap the comment list dynamically by just using the constructor and destructor functions, but I’m sure none of the other Walkers require that.

Callbacks?

In the $args for wp_list_comments(), there are 2 optional callback functions which plug into start_el() and end_el() (I believe), so if you don’t need to play with any of the other functions, this is probably a less annoying way to accomplish this. I removed that plugged-in code from this example since there is no reason to ever do a custom Walker that refers to outside functions, just pick one or the other.

Anyway, here’s the code I finally came up with:Read More …

This is the most detailed tutorial in the world (to my knowledge) on the topic of creating a WordPress theme from scratch. If you read it all, you will know everything you need to create a complete and powerful WordPress theme. The verbosity of this tutorial means it can be tailored to people of any skill level, from ace theme jockey to complete and utter beginner.

I even go so far as to break down the basics of HTML and CSS, so I do mean beginner. However, I realize not everyone needs this much detail, so I have also included links to skip past beginner sections for those are so inclined.