14

Here are some options on how we can override the native layout for each comment: Approach #1 - Overriding start_el() with a custom walker Let's define our custom wpse comment format: // Arguments for wp_list_comments() $args = [ 'style' => 'ol', 'format' => 'html5', 'short_ping' => true, ]; // Use our custom walker if it'...


11

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 name="%...


9

ok, after some research I came up with the solution. The solution is for displaying wordpress comments outside the loop and as a bonus how to place disqus comments outside the loop as well. First, How to place wordpress comments outside the loop: In single.php we need to define a new global variable for storing the post id (place this inside the loop) ...


5

In the Settings >> Discussion Screen, there is a options tick box, 'Enable threaded (nested) comments [X] levels deep'. From there you can tick to activate threaded comments and set how many levels deep to a maximum of 10. You should also check if your theme has the following piece of code, should normally be in the functions.php template of your theme. ...


5

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


5

This code will allow you to customize the comment field labels and will move the comment form below the fields. Add the code to your functions.php or to a plugin. To change the labels, modify the Name CUSTOMIZED, Email CUSTOMIZED, and Website CUSTOMIZED, and Comment * CUSTOMIZED text. /** * Customize comment form default fields. * Move the comment_field ...


4

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


4

The comments_template hook: add_filter( 'comments_template', function ( $template ) { return '/absolute/path/to/your/comments.php'; });


4

Yes you can, Frontend only you would need to check each post comment author for it's role. If the role of that comment author is not adverstisers then remove it from the array of comments attached to that post. Then you would have to return only the comments if the current logged in user is also from the advertisers role. using the comments_array filter ...


3

You should consider hooking into the comment_class() and post_class() filters, if your theme supports it. Using the comment_class filter: We can add the following filter: /** * Add a custom comment class, based on a given comment author's user meta field. * * @see http://wordpress.stackexchange.com/a/170443/26350 */ add_filter( 'comment_class', ...


3

I'm pretty sure that function tnc-remove_default_menu is not defined anywhere in your code. (You shouldn't use - character in function name in PHP). So most probably there is a function called tnc_remove_default_menu, and you've misspelled it's name in add_action/add_filter. If there is no such function anywhere in your code, then you should remove this ...


3

Check the Codex for wp_list_comments. Scroll down to the part labeled "Source File", which is there on almost every Codex entry. Click the accompanying link. And there you are. Sometimes (usually) the line number in the Codex entry is wrong though. Now you can happily go about hacking Core files and causing yourself no end of pain and heartache. If you ...


3

Just add the comments to oEmbed. Here's a small plugin that you can use as MU-Plugin or normal plugin and that should explain what's going on pretty well. <?php defined( 'ABSPATH' ) or exit; /* Plugin Name: (#105942) oEmbed Comments */ add_filter( 'comment_text', 'wpse_105942_oembed_comments', 0 ); function wpse_105942_oembed_comments( $comment ) { ...


3

You can use the provided filters to do all that: //add your checkbox after the comment field add_filter( 'comment_form_field_comment', 'my_comment_form_field_comment' ); function my_comment_form_field_comment( $comment_field ) { return $comment_field.'<input type="checkbox" name="privacy" value="privacy-key" class="privacyBox" aria-req="true"><...


3

Most likely, the 'at' is coming from the value of $comment->comment_date. If that is the case, and since we have to do with string, you could pass it from str_replace first, in order to remove the ' at', like: function my_change_comment_date_format( $date, $date_format, $comment ) { return date( 'd M Y', strtotime( str_replace(" at", "", $comment->...


2

You are using comments_template which prints out the comments and returns nothing you need to capture the comments template so try this: function get_comments_template(){ ob_start(); comments_template(); return ob_get_clean(); } and change this line: $result .= comments_template(); //Append the comments template to the result to $result .= ...


2

You can use the get_comment_author_link hook, which is part of the get_comment_author_link() template tag, like your question already suggests. Then you only have to get the according user_id, which can be done via the $comment global, and construct the link you want accordingly. Exemplary usage like shown below: add_filter( 'get_comment_author_link', '...


2

In your functions.php add ( there are other rules relating to comment pages you can see them all with Rewrite Rules Inspector plugin, this one just covers the case you mention ) add_rewrite_rule ( '(.?.+?)/customname-([0-9]{1,})/?$', 'index.php?pagename=$matches[1]&cpage=$matches[2]', 'top' ); you'll also need to find in your theme ( possibly ...


2

You can use the callback argument for a completely customized rendering of your comment/trackback function wpse168639commentCb( $comment, $args, $depth ) { // do whatever you want in here: // Dump what you got: var_dump( $comment, $args, $depth ); } wp_list_comments( array( # other arguments... 'callback' => 'wpse168639commentCb', ) )...


2

Finally I figured it out. you may simply add your arguments to the wp_list_comments as associative key => value pairs like this: $args = array( 'callback' => 'my_callback', 'avatar_size' => 48, 'type' => 'comment', 'arg1' => $arg1 ); wp_list_comments( $args ); and then in your my_callback you have: function my_callback( $comment, $args, $depth ...


2

The comments_array filter as part of the comments_template() function, the purpose of which is to load a comment template. It filters comments being prepared to be rendered in the comment section of singular type pages. The preprocess_comment and comment_post actions (in that order) both fire as part of the wp_new_comment() function, the purpose of which is ...


2

Because that's done in javascript, and you have to enqueue that javascript for it to work, as stated in the docs: If JavaScript is enabled and the comment-reply.js JavaScript is loaded the link moves the comment form to just below the comment. https://codex.wordpress.org/Function_Reference/comment_reply_link e.g. function ...


2

You should be able to do this fairly simply by hooking to the edit_comment action and saving the modified date using update_comment_meta: add_action('edit_comment', 'my_comment_modified_date', 10, 2); function my_comment_modified_date($comment_ID, $data) { update_comment_meta($comment_ID, 'modified_date', time()); }


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

This is my implementation of birgire's last suggestion (to parse the onclick): jQuery(document).on( 'click', 'a.comment-reply-link', function( event ) { // THIS PART GETS THE COMMENT ID var hayStack = jQuery(this).attr('onclick'); var strawA = '"div-comment-'; var strawB = '"'; var tipNeedle = hayStack.lastIndexOf(strawA)+strawA.length; var hayTruss = ...


1

In the simplest of explanations, the callback argument for wp_list_comments() is used to reference a function that will build the beginning of an individual comment. (The end-callback argument references a function that will close an individual comment.) So, you can use your own custom function to output an individual comment while still using the core ...


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

You could try to add your own custom get_comment_link filter just before you call the wp_list_comments() function: // Modify comment links add_filter( 'get_comment_link', 'wpse_comment_link', 10, 4 ); // Display comments wp_list_comments( $args, $comments); where our callback is defined as: function wpse_comment_link( $link, $comment, $args, $cpage ) { ...


1

Your action is called whenever comments.php loads because you're explicitly running it with do_action. Both the function and add_action should be in functions.php, and do_action should be removed entirely.


1

When registering a custom post type you need to enable comments. In the arguments defining the CPT, you need to include something like this: 'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments' ) The example on the Codex is shows where this option needs to go, this page also shows a list of other options you may or may ...


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