Im in the process of building a very custom theme and Im beginning to work on the post templates, but I dont know which hooks are essential for them.

So like, I've seen (but cant remember where)some themes or code snippets for commenting, and in the snippet the code was something like:

if comments allowed 
         comment hook

And I know there are a probably a few more for other features that Im not aware of like trackbacks right? Does anyone have a good tutorial listing out all the essentials?

  • 1
    How would you define essential? By "post templates", are you referring just to the single post page view? Also: what do you mean when you say hook? Because your example code above doesn't include a hook. – Chip Bennett Mar 12 '13 at 14:04

As a general rule of thumb it's a good practice not to "create" hooks within your theme. Last year Tom McFarlin wrote against placing custom hooks in your theme; however, if you are building an addon plugin (such as WooThemes and their Features plugin) it would make a grey area exception to include those hooks. (only for display purposes.

If you are looking for general hooks in WordPress to leverage I would recommend checking out Underscores or at very minimum the 2012/2013 core themes since they would use all the core hooks.

| improve this answer | |
  • ok maybe hooks is the wrong term, I guess I should have said functions. like get_comments(). Aren't there a whole bunch of stuff that should be on teh posts pages. Functions for comments (and a conditional to see if commenting is enabled) and trackbacks and such? – rugbert Mar 14 '13 at 14:42
  • Per the core documentation there is a central page for documenting conditionals. The easy ones specifically for comments, pings, and trackbacks. I think specifically you might want to check out the function reference since it is constantly evolving and improving to document the code experience for core functionality. – codearachnid Oct 1 '13 at 14:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.