You can follow any responses to this entry through the RSS 2.0 feed.
You can leave a response, or trackback from your own site.
Advertise
Best Hosting Service
Categories
- CMS Tools (1)
- Coding (6)
- CSS (13)
- Fonts (16)
- Freelance (16)
- Graphics (880)
- HTML (6)
- Icons (21)
- Illustrator (1)
- Inspiration (45)
- Interviews (8)
- IPhone (1)
- Java Script (4)
- Jquery (1)
- Logos (7)
- Marketing (5)
- Megento (1)
- Mobile Apps Development (2)
- News Letter (1)
- Photoshop (5)
- Resources (3)
- Responsive Design (2)
- Tutorials (4)
- Twitter (6)
- UI Design (1)
- UX Design (3)
- Wallpapers (7)
- Web Design (45)
- WordPress (23)
- Work (9)
Tags
3D
Artworks
brush
clients
Create
CSS
CSS3
design
designs
developers
Download free fonts
Fonts
Free
free fonts
Free Icons
Freelance
freelance websites
Graphics
Icon
Icons
Illustration
Illustrations
Illustrator
Inspiration
Inspirational
Interview
Javascript
Logos
Photo
photos
Photoshop
portfolio
Poster design
Texture
themes
tutorial
tutorials
Twitter
Typography
UI design
Vector
Web Design
Websites
WordPress
Wordpress Themes



Custom Comments HTML Output
Displaying all the comments on a Post is incredibly easy. In your single.php file you probably have a line like this:
That line basically calls/includes your comments.php file. Within that, the line to output all comments is something really simple like this:
But that doesn’t leave much by way of customizing the HTML that gets output, does it? Fortunately it’s fairly easy to specify your own formatting in a non-destructive non-core-altering way. Although personally, I’m having one little issue with it. Let’s take a look.
Why would you need this?
This is what you get as the defacto standard comment output:
This is from the new 2010 theme slated to come out with WordPress 3
But what if you wanted something more like this?
From a new client site I’ve been working on
The best way to get into that new skin is to get your hands on the HTML, as CSS alone isn’t quite going to get us there.
Custom output through a callback function
The trick is is that the wp_list_comments function accepts a parameter for a callback function. This function overrides what the output of each comment will be. Here is an example of that:
The above code will only output “comments” (and not trackbacks or pingbacks) and will call a custom function “format_comment” for formatting the comment. This function needs to be built in your functions.php file, and better be present before you call this function otherwise you’ll throw an error.
The callback function is completely in charge of the comment formatting. It could be something completely whacky like this:
Which would return that ridiculous sentence for every single comment, instead of the actual comment. Of course you wouldn’t (probably) ever do that. What you probably want to do, is just adjust how the different standard comment-related data is output. To do that, first you pull in the comment globals, then you can use all the comment functions that return the stuff that you probably want:
Here is a customized formatting function I recently used:
Related Posts