14
votes
Accepted
Change HTML Produced by wp_list_comments()
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 ...
12
votes
Accepted
How to wrap submit button of comment form with div
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" /&...
6
votes
Accepted
Override comments.php template with plugin
The comments_template hook:
add_filter( 'comments_template', function ( $template ) {
return '/absolute/path/to/your/comments.php';
});
5
votes
Accepted
customize comment form
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 ...
5
votes
How to wrap submit button of comment form with div
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( ...
4
votes
Comment Walker vs. Comment Callback
We could rewrite:
wp_list_comments( array(
'callback' => 'bootstrap_comment_callback',
));
with the null walker parameter:
wp_list_comments( array(
'walker' => null,
...
4
votes
Accepted
Showing comments only to same custom user role
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 ...
4
votes
Why does comment_reply_link launch the reply form at the wrong spot on the comment section?
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 ...
3
votes
Accepted
Remove "at" string from wordpress comment date
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 '...
2
votes
Comment Walker vs. Comment Callback
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 ...
2
votes
Accepted
Order of Operation for these three hooks
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 ...
2
votes
Accepted
Check if comment was modified
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);...
2
votes
Accepted
How to make comments private for commentor and post author
You can use the pre_get_comments filter to modify the parameters of the comment query before it fetches the comments. Specifically the author_in parameter.
I tried to write an example, though I haven'...
1
vote
Make comment textarea input un-required
After a lot of trial-and-error from other questions and sources, I discovered the allow_empty_comment filter.
This simple filter allowed me to submit comments without filling in the actual "...
1
vote
Name of comment field differs on different sites
@JacobPeattie Forget my last answers. You are absolutely right, Antispam Bee was the cause. I didn't install it on the second site. After installing it, I also have there now an obfuscated name. ...
1
vote
Accepted
How do I change parameters without changing the core
If you scroll further down the comment-template.php file, you'll notice that the next available filter you can use is comment_form_defaults. With this filter you can change the default comment form ...
1
vote
How can I show comments in random order?
Never actually had a need for this but you will need to use the WP_Comment_Query function. There is this handy comments query generator online to customize this query easily.
But wait, it doesn't ...
1
vote
Comments to only be seen by their author
The filter that you mention modifies the result of the get_comments function after it has been fetched. However, you can also parse arguments to this function. You can see which arguments here. As you ...
1
vote
Accepted
Non-Blog Website without Search: are comments.php and search.php in theme still required?
According to the documentation, the only required files in a theme are style.css and index.php. All other files are optional. You can use the ones you need and discard the ones you don't need.
If you ...
1
vote
How to add a title field in comments?
Based on this tutorial , here is an answer to a similar question.
This may also help.
I hope this will help you start your journey by some tweaks and adjustment with code.
1
vote
The comment could not be saved. No comment_ID on comments
I had the same problem and it was indeed solved by turning on Auto_Increment (A_I) for "comment_ID". Here's how to do that: https://stackoverflow.com/questions/5665571/auto-increment-in-phpmyadmin
In ...
1
vote
How to display comment meta under each comment content
You will need get_comment_meta to pull that information from the database. You will need to know the metakey. If you don't have that, you will have to search the theme/plugin that generates the ...
1
vote
What does the "$depth" parameter in the Walker_Comment stand for?
The $depth parameter in the walker class is used for outputting and padding the output. You can use it to format your HTML structure. For example:
<div class="comment-meta post-meta cmnt-padding-&...
1
vote
Accepted
Change the HTML of the comment form that is generating somewhere from the core Wordpress
You can write your own custom HTML structure for comment listing. Inside your comments.php file, there will be a call to wp_list_comments() function. Find it, and pass your own function as its ...
1
vote
Customizing comments pagination for bootstrap
Just replace that snippet for this one:
<?php
$pages = paginate_comments_links(['echo' => false, 'type' => 'array']);
if( is_array( $pages ) ) {
$output = '';
...
1
vote
Check if the current user is author of first comment
Helper function
Here's a helper function (untested) to check if a given user ID is the first commenter for a given post ID:
/**
* Check if a given user ID is the first commenter for a given post ID
...
1
vote
how to get the comment ID in the front end when the REPLY button is clicked?
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 ...
1
vote
Accepted
How can I embed comments plugin to my own website?
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
...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
comments-template × 107comments × 85
comment-form × 31
functions × 13
plugins × 8
php × 7
posts × 6
comment-meta × 5
plugin-development × 4
customization × 4
theme-development × 4
custom-post-types × 3
themes × 3
templates × 3
walker × 3
paginate-comments-links × 3
wp-admin × 2
hooks × 2
users × 2
urls × 2
html × 2
author × 2
links × 2
wp-query × 1
custom-field × 1