Hot answers tagged

5

Comment.php The way I see your comment.php seems messy and more complex than it needs to be, you can post this piece of code to in your comment.php and it should work okay. <?php /** * If the current post is protected by a password and * the visitor has not yet entered the password we will * return early without loading the commend */ if ...


4

We can use comment_form function's submit_button parameter to change submit button HTML. Default HTML for submit_button is <input name="%1$s" type="submit" id="%2$s" class="%3$s" value="%4$s" /> You can change your code like this. $comments_args = array( .... 'submit_button' => '<div class="form-group"> <input ...


3

Please place below code in your theme's functions.php file and it will wrap the submit button inside div: // define the comment_form_submit_button callback function filter_comment_form_submit_button( $submit_button, $args ) { // make filter magic happen here... $submit_before = '<div class="form-group">'; $submit_after = '</div>'; ...


3

We could rewrite: wp_list_comments( array( 'callback' => 'bootstrap_comment_callback', )); with the null walker parameter: wp_list_comments( array( 'walker' => null, 'callback' => 'bootstrap_comment_callback', )); which means we are using the default Walker_Comment class: wp_list_comments( array( 'walker' ...


3

If you need to modify the max depth, you could use the thread_comments_depth_max filter: /** * Set max comments depth to 15 on the discussion settings page */ add_filter( 'thread_comments_depth_max', function( $max ) { return 15; } ); then the dropdown on the discussion settings page will show the range 1 - 15. But I can imagine very deep comment ...


2

By default WordPress organizes the comment pages from oldest to newest. This does not change, even if the Settings-Discussion options have been modified. This is the sticking point, one might suspect changing these settings to reorganize the comment pages, it doesn't. These settings, basically, define comment order in the default comment loop, and what page ...


2

Re-arranging the comment fields The comment text area has been moved to the top in WordPress 4.4: What if we prefer the old setup, where it was at the bottom? Re-arranging the author, url and email comment fields We can modify the display order, of the author, url and email fields, with: /** * Re-arranging the author, url and email comment fields */ ...


2

The link markup passes through the filter named, guess what, cancel_comment_reply_link. Something along the lines of (not tested): add_filter( 'cancel_comment_reply_link', function( $formatted_link ) { return 'before' . $formatted_link . 'after'; } ); It will still get wrapped into <small> in comment_form() later though, which might or might ...


2

You can use output buffering to achieve this effect: function get_comments_form() { ob_start(); comments_form(); $commentsform = ob_get_contents(); ob_end_clean(); return $commentsform; } $commentsform = get_comments_form();


2

Sure, you could use the comment_form_field_comment filter to inject content (extra fields or whatever) above the comment field: function comment_form_field_comment_add_field( $field ) { $new_field = '<p class="comment-form-extra"><label for="extra">Extra Field</label> <input id="extra" name="extra" type="text" value="" size="30" ...


1

The comment_text filter passes the comment as one of its params: echo apply_filters( 'comment_text', $comment_text, $comment, $args ); So you don't need to call get_comment_ID(), you can just access the ID from the $comment object. Change: add_filter( 'comment_text', 'modify_comment'); to: add_filter( 'comment_text', 'modify_comment', 0, 3 ); And ...


1

The visual representation of a comment form (or lack of it) do not have any impact on the ability to receive comments, and spammers usually don't care at all what is in your form. Wordpress have a well publicized end point to which all comments are being sent (and while I don't remember the detail off the top of my head right now) and spammers can post to ...


1

Take a look at rendering a comment_form. You can render it anywhere in your page template and there are lots of ways to customize it. $comments_args = array ( // change the title of send button 'label_submit' => 'Send', // change the title of the reply section 'title_reply' => 'Leave Your Comment', // remove "Text or ...


1

It seems WP core adds the novlidate attribute to the comment form when your theme has HTML5 support enabled for comment forms (see includes/comment-template.php). To disable it, use remove_theme_support('html5', 'comment-form');


1

You could use flexbox instead of table if wanting to do this with css. Flexbox lets you order elements easily: #commentform { display: flex; flex-flow: column; } .comment-form-comment { order: 1; } .comment-form-url { order: 2; } .comment-form-email{ order: 3; } .comment-form-author{ order: 4; } .form-submit{ order: 5; } Here's ...


1

I'm not sure I fully understand your question, but to add some HTML (just over or under the submit field) that is visible to both logged-in and logged-out users, you can try the following: add_filter( 'comment_form_submit_field', function( $submit_field ) { //----------------------------------- // Adjust the prepend to your needs ...


1

Welcome to WSE. This tut maye be helpful http://www.sitepoint.com/design-a-multi-page-form-in-wordpress-introduction/ However, I don't see why you wouldn't use a form plugin to achieve this. Any of the following should do the job for you Breezing Forms, Gravity Forms, Contact 7 forms, Formidable Forms, Easy Form Maker, Ninja Forms, Contact Form Manager, ...


1

WP_Comment_Query doesn't pull comment meta. You can search by comment meta but the query doesn't return that data. You could easily check this yourself by looking at the Codex. You need to loop over the results and run get_comment_meta(), or essentially do the same via a filter on the_comments. It is also possible to add to the data returned by filtering ...


1

You should be able to change the HTML structure for the comment form's submit, with the comment_form_defaults filter. Here's an untested example: add_filter( 'comment_form_defaults', function( $defaults ) { // Edit this to your needs: $button = '<input name="%1$s" type="submit" id="%2$s" class="%3$s" value="%4$s" />'; // Override the ...



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