Hooks for Comments Plus

Out of the box, the plugin isn’t working with my theme. How do I find the hooks that my plugin is using?


  • DavidM
    • DEV MAN’s Mascot

    Hi kbaxter,

    I misunderstood the thrust of your post initially. To find the hooks your theme is using you can check out your comments.php file, where you’d usually find comment_form(). If not though, you may be able to add that in, or you can see what others it does use via any apply_filter() or do_action() functions.



  • Donald McIntyre
    • Design Lord, Child of Thor

    Hi DavidM:

    Can you tell me what are the two hooks I need for BuddyPress Deafault Theme?

    Am I too lazy? Then the question is: If I find in comments.php file comment_form() I put:

    comment_form in both hook spaces in the plugin? or the full line, comment_form()?

    If not Im lost!!

    Cheers, Donald.

  • Tee
    • The Crimson Coder

    Same problem here. What are the right hooks?

    My theme’s single.php is calling comments by <?php comments_template(”, true); ?>

    As far as I understand the part within comments.php showing the comments is the following:

    if ( have_comments() ) : // if there are comments ?>


    <div id="comment-wrap" class="clearfix">

    <?php if ( ! empty($comments_by_type['comment']) ) : // if there are normal comments ?>

    <h3 id="comments">
    <?php comments_number(__('No Comments', 'framework'), __('One Comment', 'framework'), __('% Comments', 'framework'));?> <?php _e('on', 'framework'); ?> "<?php the_title(); ?>"</h3>

    <ol class="commentlist">
    <?php wp_list_comments('type=comment&avatar_size=66&callback=tz_comment'); ?>

    <?php endif; ?>

    <?php if ( ! empty($comments_by_type['pings']) ) : // if there are pings ?>

    <h3 id="pings"><?php _e('Trackbacks for this post', 'framework') ?></h3>

    <ol class="pinglist">
    <?php wp_list_comments('type=pings&callback=tz_list_pings'); ?>

    <?php endif; ?>

    <div class="navigation">
    <div class="alignleft"><?php previous_comments_link(); ?></div>
    <div class="alignright"><?php next_comments_link(); ?></div>

    What ‘hooks’ would I use?


  • Vladislav
    • Dead Eye Dev


    If you don’t see the plugin comments interface, it is likely that your theme doesn’t implement the hooks we need to connect to it Often, your theme will expose another set of hooks that we can use instead of the default ones. To see if that is the case, open your theme’s comments file (it will usually be something like <your-wp-install-folder>/wp-content/themes/<your-theme>/comments.php) in a text editor. Look for lines that look like this:

    <?php do_action("some_action_name"); ?>

    Take note of my_action_name string – this is the action name, which is what we’ll use to try and hook up to next.

    Go to your plugin settings, and type the action names you just found into your custom hooks boxes (just the name, without quotes – make sure you type it exactly as it is in your file. Casing and underscores matter). Save your settings and check the results on your page(s). If you’re satisfied with the results, you’re done! This is exactly what worked for Donald.

    If you’re still experiencing problems or the placement doesn’t look right, you may want to repeat the process and try to hook into another place, using another hook name mentioned in your file.

    If using existing hooks didn’t produce the results you’re after, you can alter your theme file to include the hook we need. To achieve this, you can either just add the plugin default hooks (this is what Thorsten did), or create a new, custom one.

    Just adding the default hooks is easier, but it may or may not be the best idea for your particular case. The plugin uses default WordPress hooks, which often have meaning outside the plugin scope, and just throwing that in may have undesired consequences (it probably won’t, though). Instead, you may want to create a totally new, custom set of hooks that will be meaningful in your specific case only. Fortunately, that is not too hard.

    First off, you may want to think of a name for your hooks. It should be something fairly unique, so that it doesn’t clash with or trigger something else. You may also want to use something descriptive and mnemonic, so you know what you added and why later on.

    Next, open up your theme’s comments file in a text editor, and find a place you want plugin output to appear. Make sure it’s not within PHP tags, and add this line:

    <?php do_action("my_action_name_start"); ?>

    Next, scroll a bit down and add in this line:

    <?php do_action("my_action_name_end"); ?>

    Of course, substitute my_action_name_start and my_action_name_end with the actual action name you came up with. That’s it, you just made a new set of custom hooks the plugin can use to connect to.

    Go to your plugin settings, and type the action names you just added into your custom hooks boxes (just the name, without quotes – make sure you type it exactly as it is in your file. Casing and underscores matter). Save your settings and check the results on your page(s).

    If you want to just use the plugin default set of hooks, the process is quite similar – you still need to add “do_action” lines to your theme’s comments file, but just use the lines Thorsten posted instead of the ones above.

    Sorry for the long post, but I hope this helps.

  • gplusbox
    • New Recruit

    Hello, open comments.php in dashboard WordPress.

    Find <?php do_action(‘comment_form’, $post->ID); ?> and delete it.

    Then, add “<?php do_action(‘comment_form_before’, $post->ID); ?>” before “<?php if ( get_option(‘comment_registration’:wink: && !$user_ID ) : ?>” and add “<?php do_action(‘comment_form_after’, $post->ID); ?>” after “<p><input name=”submit”…</p>

    Demo in my comments.php and works fine:

    <?php do_action('comment_form_before', $post->ID); ?>
    <?php if ( get_option('comment_registration') && !$user_ID ) : ?>
    <p><input name="submit" type="submit" id="submit" tabindex="5" value="<?php echo attribute_escape(__('Submit Comment')); ?>" />
    <input type="hidden" name="comment_post_ID" value="<?php echo $id; ?>" />
    <?php do_action('comment_form_after', $post->ID); ?>

    Demo in site: http://svip.info/car-reviews/bugatti-veyron-eb-16-4-the-fastest-car-in-the-world.html

    Have fun!

  • Jack
    • New Recruit


    I am using the P2 theme. Initially it was not working but after i added hooks it worked in some instances but behaves erratically.

    Can you advice me where and how to add proper hooks – I also use the Ultimate Facebook plugin – have de-activated it and checked – the problem remains.

    Below is the code in P2 for comments entry:

    * Comments
    $comment_field = '<div class="form"><textarea id="comment" class="expand50-100" name="comment" cols="45" rows="3"></textarea></div> <label class="post-error" for="comment" id="commenttext_error"></label>';
    $comment_notes_before = '<p class="comment-notes">' . ( get_option( 'require_name_email' ) ? sprintf( ' ' . __( 'Required fields are marked %s', 'p2' ), '<span class="required">*</span>' ) : '' ) . '</p>';

    $p2_comment_args = array(
    'title_reply' => __( 'Reply', 'p2' ),
    'comment_field' => $comment_field,
    'comment_notes_before' => $comment_notes_before,
    'comment_notes_after' => '<span class="progress spinner-comment-new"></span>',
    'label_submit' => __( 'Reply', 'p2' ),
    'id_submit' => 'comment-submit',

    <?php if ( get_comments_number() > 0 && ! post_password_required() ) : ?>
    <div class="discussion" style="display: none">
    <?php p2_discussion_links(); ?>
    <a href="#" class="show-comments"><?php _e( 'Toggle Comments', 'p2' ); ?></a>
    <?php endif;

    Please help!



  • Timothy
    • Chief Pigeon

    Hey there.

    Thanks for posting in this thread, however it might be best if you open your own, even if the issues seem closely related. That way it will remain independent of this one and ensure it doesn’t confuse issues here if this thread needs reopening again by the author.

    Posting on old threads can also lead to us missing your questions, which is what happened here. :slight_frown:

    It also means the member who started this thread or anyone following it isn’t inundated with post notifications each time we respond to each other. A lengthy thread could annoy the original

    This also allows us to better track and answer your questions to ensure we don’t miss any for ya.

    You can start a new thread here:



Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.