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: ...


7

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

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


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

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

In your comments.php template file use wp_list_comments and set the parameter callback to your defined function that will generate the template. Inside the function you can style the comment reply link. wp_list_comments codex Further reading on comment display


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

The wp_list_comments() call accepts a callback argument, in which you can define the specifc comment-list markup that you want. I would suggest taking a look at how TwentyTen handles the wp_list_comments() callback.


3

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 ...


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 ) ...


3

Filter comment_form_defaults and add your code to the textarea. Sample code, not tested: add_filter( 'comment_form_defaults', 'wpse_120049_extend_textarea' ); function wpse_120049_extend_textarea( $args ) { $args['comment_field'] .= '<p>Extra text.</p>'; return $args; }


2

You can store these values in cookies and fill them when you are creating form inputs. So in save_comment_meta_data add something like this: $commenter_data = array( 'phone' => $phone, ... ); setcookie('commenter_data', serialize($commenter_data), time()+1209600, COOKIEPATH, COOKIE_DOMAIN, false); And then when you're creating form: ...


2

After checking out the code, the best way to do this would be to use the wp_editor_settings filter in /wp-includes/class-wp-editor.php. When you call wp_editor() it internally makes a call to _WP_Editors::editor($content, $editor_id, $settings);. This function first passes the $settings array through parse_settings() which uses that filter. add_filter( ...


2

parent : Comments can be replies to other comments. Every comment has an ID number. When the comment is a reply, then it will have a "parent" which is the ID of the comment it is replying to. Putting a comment ID in here will get all the replies to that comment. post_parent : Posts can be children of other posts as well. This is how things like hierarchical ...


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.



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