Tag Info

Hot answers tagged

8

Hi @Emerson: Do you want before the list of comments or before the comment form (I assume the latter?) If yes, and I'm assuming you are either using the TwentyTen theme or a theme that uses the new comment_form() function from WordPress 3.0.0? If so it's as simple as using the 'comment_form_before' hook. Here's an example you can place in your theme's ...


7

Create a file in wp-content/plugins/ with this code: <?php /* Plugin Name: Get Rid of Comment Websites */ function my_custom_comment_fields( $fields ){ if(isset($fields['url'])) unset($fields['url']); return $fields; } add_filter( 'comment_form_default_fields', 'my_custom_comment_fields' ); Normally, I'd say put it into your theme's ...


7

That's pretty simple. You just have to take the textarea out of the default fields – filter 'comment_form_defaults' – and print it on the action 'comment_form_top': <?php # -*- coding: utf-8 -*- /** * Plugin Name: T5 Comment Textarea On Top * Description: Makes the textarea the first field of the comment form. * Version: 2012.04.30 * Author: ...


6

I'm working with the Foundation framework as well. I've found that the easiest way to add a class to a non-filterable element is to do it with jQuery. jQuery(document).ready(function($) { //noconflict wrapper $('input#submit').addClass('button'); });//end noconflict


6

For people that come here looking for a more detailed explanation about the text domain issue instead of just "use a text domain". Here's how it works. Firstly, you have to tell WordPress where the language files should be put in your theme, and what the 'theme slug' is (a unique identifier for your theme) like so: add_action('after_setup_theme', ...


6

I know this is quite an old post and maybe this could help someone. You can replace the class of an element using add_filter(); Here's an example: // filter to replace class on reply link // class name function name add_filter('comment_reply_link', 'replace_reply_link_class'); function replace_reply_link_class($class){ $class ...


6

Short answer: It doesn't, but you can get around this: add_filter('comment_form_field_comment', 'my_comment_form_field_comment'); function my_comment_form_field_comment($default){ return false; } add_action('pre_comment_on_post', 'my_pre_comment_on_post'); function my_pre_comment_on_post($post_id){ $some_random_value = rand(0, 384534); ...


6

There are a couple other hooks in the comment form that you can use. Where you're hooking on only displays if the user isn't logged in. If you want that field for all users (logged in or not), you need to add your form by hooking into both comment_form_after_fields and comment_form_logged_in_after, both of which are actions, and echo out the new field. ...


5

If you check out the source of the function comment_form(), you'll see it doesn't even print a class on the input; <input name="submit" type="submit" id="<?php echo esc_attr( $args['id_submit'] ); ?>" value="<?php echo esc_attr( $args['label_submit'] ); ?>" /> I'm guessing you need to add a class for styling? Why not modify your CSS to ...


5

Filter comment_form_field_comment to add a select element with a label. Add a callback to the action comment_post to save the value. Filter comment_text to show the value for a comment. Sample code: add_filter( 'comment_form_field_comment', function( $field ) { global $wp_roles; $user = wp_get_current_user(); $select = ...


5

you might find these links handy if you're going to code it yourself http://byronyasgur.wordpress.com/2011/06/27/frontend-forward-facing-ajax-in-wordpress/ http://www.garyc40.com/2010/03/5-tips-for-using-ajax-in-wordpress/ I am fairly sure your URL is wrong url: "../wp-comments-post.php" - ajax in wordpress has to be sent (quite strangely) to/through ...


4

When we post an empty anonymous reply, we get the following errors: The part of BBPress that's responsible for handling this, is the bbp_new_reply_handler() function, in the file /bbpress/includes/replies/functions.php. It contains these lines that are of interest to us: // User is anonymous if ( bbp_is_anonymous() ) { // Filter ...


4

You are probably looking for Jetpack comments system. If so, you can install Jetpack plugin and then activate the Comments module, if it is not activated by default upon plugin activation. After plugin installation, you may also need to connect to your WordPress.com account to enable any (or all) Jetpack features as indicated in the installation ...


4

You could just take a look at the Codex Page for wp_list_comments which has some example code for customising comment listings. You will see from that page that you can add a callback function to wp_list_comments which is normally used to customise how comments are listed


4

To save your extra field, you have to do : function save_comment_meta_data( $comment_id ) { add_comment_meta( $comment_id, 'extra_field', $_POST[ 'extra_field' ] ); } add_action( 'comment_post', 'save_comment_meta_data' ); See this nice tutorial covering extra fields in comment forms.


4

Don't link the script file directly. Enqueue it instead, e.g. in functions.php: function mytheme_enqueue_comment_reply() { // on single blog post pages with comments open and threaded comments if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) { // enqueue the javascript that performs in-link comment ...


3

I can think of only following ways to achieve this. There is a filter "comments_open" that check if the post whose $post_id is provided has comments open. You can use that to return false. There is another filter "comments_template" that return the template file to be used to display comment form. You can return an empty file and hence no comment form will ...


3

This code makes no sense: function my_fields($fields) { $fields['new'] = '<p>red rover 1</p>'; return $fields; } add_filter('comment_form_top','my_fields'); I'm not even sure what it's supposed to do, because comment_form_top is an action, not a filter. If you want to add extra fields, you should be using the comment_form_default_fields ...


3

Just add it in before the comment function (unless I misunderstood something?): <div class="policy">policy text</div> <?php comments_template(); ?> This would be on single.php, page.php


3

wp_list_comments() uses Walker_Comment class (that extends generic Walker) to generate output. If you need extensive customization you should extend Walker_Comment with your own class and pass instance of it as walker argument to the function.


3

I liked toscho answer. However I wanted to use a custom textarea, so it didn't work in that case. I used the same hooks but with separate functions: add_filter( 'comment_form_defaults', 'remove_textarea' ); add_action( 'comment_form_top', 'add_textarea' ); function remove_textarea($defaults) { $defaults['comment_field'] = ''; return $defaults; } ...


3

Quite old post, but while searching I came here, maybe someone else will find it useful. The only solution I found is to completely rebuilt the button that comment_reply_link returns. I first made two vars reconstructing href and onclick attributes for the reply button: $reply_href = wp_make_link_relative( get_permalink( $comment->comment_post_ID ) ...


2

You have commenting turned off for logged-out users. To change this setting, visit the Settings > Discussion page in your WordPress admin and uncheck the Users must be registered and logged in to comment box. Remember to update the setting by clicking the Save Changes button.


2

Edit your comments.php template and add in <ol class="commentlist"> <?php wp_list_comments(); ?> </ol> This should display comments, pingbacks and trackbacks. See the Codex for wp_list_comments() for help on how to style and separate or to display just comments.


2

This is hard. Output buffering could solve that: add_action( 'comment_form_field_comment', 'ob_start' ); add_action( 'comment_form', 'wpse_83898_replace_submit' ); function wpse_83898_replace_submit() { $html = ob_get_clean(); # do some magic echo $html; } Just an idea, not tested.


2

Don't build your own form and don't modify comments.php - it's purpose is little bit different and I don't think you should include it inside sidebar. Just put comment_form function call in your sidebar template. It takes 2 parameters: args and post_id. So you can do it like this: $args = array( ... // your custom arguments (you can leave it empty ); ...


2

You have to set the value of $_POST['comment_post_ID'] to the post id of the page: <input type='hidden' name='comment_post_ID' value='10' /> Then set the action of the form element to /wp-comments-post.php, filter 'comment_post_redirect' and send the visitor back to page where the comment/review was written. Here is an example, written as plugin: ...


2

Ensure that you have Threaded Comments enabled: go to Dashboard -> Settings -> Discussion and enable the option to thread comments Ensure that your Theme enqueues the comment-reply script. Look for the following, usually in header.php, functions.php, etc.: <?php wp_enqueue_script( 'comment-reply' ); ?> Note: this call is usually wrapped in a ...


2

This works fine for me: <?php add_filter('comment_form_default_fields', 'wpse53687_filter_fields'); /** * Unsets the email field from the comment form. */ function wpse53687_filter_fields($fields) { if(isset($fields['email'])) unset($fields['email']); return $fields; } One reason that it could be failing on your theme is that args ...


2

Comment is Easily Customaziable. for example: code for cancel the reply link <?php cancel_comment_reply_link(); ?> if you want custom the Text like Reply means Replace Text... <?php cancel_comment_reply_link(text); ?> Text to display as a link. If empty, it will return the default: 'Click here to cancel reply.'it should be work.



Only top voted, non community-wiki answers of a minimum length are eligible