Comment Form Hooks Visualized

Most themes (e.g. TwentyTen) use the comment_form() function to insert the comment form after posts. There are quite some hooks inside the function but they are hard to localize. The codex documentation isn't too helpful, neither.
To give you an easy overview the following diagrams visualize the points where the various hooks are anchored. The number of available hooks depend on the discussion settings and the user's capabilities.

In the most common scenario the user is not logged in, is allowed to comment on the article and the comments are not closed:

There are six hooks available:

  • comment_form_before
  • comment_form_top
  • comment_form_before_fields
  • comment_form_after_fields
  • comment_form
  • comment_form_after

You might have noticed that the hooks comment_form and comment_form_after seem to be anchored almost at the same point but depending on the user's role and discussion settings they are not always available so you should take care which hook you are using in your code.


User logged in
If you are logged in you have fewer hooks available since the name, email and URL input fields are not needed. The missing hooks are

  • form_comment_before_fields
  • form_comment_after fields


User is not logged and "Users must be registered and logged in to comment" activated
If your blog is configured that only registered users can comment, an unregistered user will see this comment form and additionally the hook comment_form_must_log_in_after is available. Please notice that in this case the hook comment_form is left out.


Comments closed
If the comments on the post are closed you have only one hook left (comment_form_closed) since the form is not displayed at all:

Post Formats – More Creative Ways For A Theme


First day of our Advent Calendar we show tiny code snippets and brief informations for the Post Formats from WordPress version 3.1.

Some theme authors wanted more defined formats - they wanted the feature "post formats". This new functionality will be available in WordPress 3.1 and displays an additional meta-information. The Codex for this functionality is available already, and now it's up to the theme authors to use this new feature.
Continue reading …

Individual Design for any Page

The blog has a Theme and for every page an extra style sheet. This current trend of individuality for each content is very common today. Even with WordPress, you can do so; there are several possibilities. One possibility is to create, based on the title, the individual stylesheet.
By default, the class assignment of function body_class() has already a lot of possibilities. More individuality can be reached with the title or ID.
It is certainly not worth for a traditional blog environment but for a site with little content it works pretty well. As I have implemented in this case.
Continue reading …