Hardware and software setup

WordPress comments are the complete look and feel. Setting up comments in WordPress Posted send a comment comment

To be honest, when I saw that they write about this and advise newcomers on other sites, I was a little horrified and decided to file my note on this topic without a fatal flaw. Basically, I have seen long pieces of code that implement adding comments to the site. Usually, a form is created for this, its processing, saving, as well as selections for display are implemented. But the advantages of this approach the further, the less.

In this post, you will learn one of the easiest (but subjectively one of the most preferred) ways to add comments to a site - a simple example for newbies + options for more advanced webmasters.

Indeed, why reinvent the wheel and write a bunch of code that will still have to be supported, fixed, etc. in the future, if there are a bunch of ready-made solutions from third party services(this is about in social networks + discus)?

But before we move on to the actual implementation, let's look at the advantages / disadvantages of using ready-made solutions. (If you forgot something - write in the comments - we will expand the list)

Benefits of third party solutions:

  • Ease of implementation.
  • Spam protection "out of the box" (in my solution, I would have to implement this additionally, so, theoretically, it is related to the previous paragraph).
  • Less prone to bugs, bugs, etc., since third-party solutions have been tested by millions of users (again related to the first: you can also write everything without bugs, but it will take extra time to debug).
  • As a rule, services provide a ready-made admin panel, statistics, notifications for admins, sometimes moderation, several admins, pre-moderation, etc., which can take months, if not years, for a webmaster, especially a beginner, to implement.
  • The user does not need to register, enter his name, etc. - it is assumed that he already has an account in the popular social network.
  • Most likely to last heavy load because the social Platforms were originally designed for heavy loads.

Flaws:

  • Lean or complete absence the ability to change the appearance of the block with comments.
  • Indexing in search engines.

As you can see, there are many more benefits. The inability to change the appearance is most likely done in order to recognize the style of the comment service, thus creating unobtrusive advertising. (As one of the options). As for indexing, is it really that important, because not all comments carry a semantic load.

But enough theory, let's move on to practice.

1. The simplest option is to add comments using some selected social network.

For example vk. We look at the documentation. Copy the provided code and add it to the page (code pieces are taken from the docks by reference, may change in the future, so always copy from the documentation site. Here is just a possible example):

1) Add to :

2) Add in the place where we want to see the comments widget (for example, after the note, if we are talking about a blog):

2. Add widgets from multiple services. For example, as on this resource. Switch tabs:


We add to the markup (for correct work, twitter bootstrap must be connected!) in the place where you want to display comments widget:

But this option is not the best, although the easiest. The problem is that with this approach, all widgets will be initialized when the page loads, regardless of whether the user needs them or not.

This can be avoided by implementing lazy initialization of comment widgets. First the whole code, then the explanation:

(function(global, $) ( "use strict"; $(function() ( var $tabToggler, initComments, initialized; initialized = ( "#vk-comments": false, "#disqus_thread": false ); initComments = function (type) ( var discussUserName, disqus_config, pageUrl; if (initialized) ( return; ) pageUrl = "page_url"; switch (type) ( case "#disqus_thread": // You need to set this params using your platform"s appropriate way discussUserName = "discussUserName"; disqus_config = function() ( this.page.url = pageUrl; return this.page.identifier = "page_identifier"; ); (function() ( var d, s; ​​d = document; s = d.createElement("script"); s.src = "//" + discussUserName + ".disqus.com/embed.js"; s.setAttribute("data-timestamp", +new Date()); return ( d.head || d.body).appendChild(s); ))(); break; case "#vk-comments": VK.Widgets.Comments("vk-comments", ( limit: 5, attach: " *", pageUrl: pageUrl )); break; default: return; ) initialized = true; ); $tabToggler = $(".comments-wrapper a" ); $tabToggler.on("shown.bs.tab", function(e) ( initComments($(e.target).attr("href")); )); initComments($tabToggler.closest(".active").find("a").attr("href")); )); ))(window, jQuery);

Pay attention to the variables whose value you must prepare using the methods provided by your platform.

First we create a type mapping comment widgets, variable initialized. Next, the function initComments(type) allows initialize comment widget, and it does nothing if it has already been initialized.

And the final touch - initialize the default comments widget so that it is displayed immediately after the page loads.

Ready script on and coffeescript on gist. An example of work is below (code examples are taken from this site)

This name does not interfere with many, but sometimes the question arises how to change add a comment to leave a review or the like. In this case, this article will help you. As I wrote above, I will show a couple of ways.

Method number 1

For the first method, you must find the file in the folder with the theme that is installed on your site. comments.php. If there is one, open it and look in it for an array responsible for setting up and displaying the content of the comment form. It looks something like this:

$args = array("comment_notes_before" => "

", "comment_field" => "

", "id_submit" => "comm_subm", "label_submit" =>

So, to this array, you need to add new parameter With desired value and all. In our case, this is:

"title_reply" => "Leave your own review",

How do you understand - Leave your review, this is the new name instead of - Add a comment. You can add such a parameter to the end or to the beginning of the array. It will turn out something like this:

$args = array("title_reply" => "Leave your comment", "comment_notes_before" => "

Fill in the fields below. Your e-mail will not be published. Required fields are marked *

", "comment_field" => "

", "id_submit" => "comm_subm", "label_submit" => "Submit",); comment_form($args);

Added to the beginning and now, on the pages of entries, a line will be displayed - Leave your review. This method is not complicated and requires minimal effort, the main thing is to correctly define the array. But sometimes it happens that there is no comments.php file inside the theme or there is no array in it and you don’t know how to add it there correctly, then the second method will help you.

Method number 2

The essence of the second method is to add new feature, which will make the replacement of the name. To do this, in the folder with the active theme, you need to find the file functions.php With custom functions and to a convenient place, if you do not know this, then to the very end before the closing PHP tag - ?> , if there is none, then just at the very end, add the following code:

Function wph_change_submit_label($defaults) ( $defaults["title_reply"] = "Submit Your Feedback"; return $defaults; ) add_filter("comment_form_defaults", "wph_change_submit_label");

Bonus

This is the same, in fact, what was done in the first method, simply, there we embedded directly into the array, and here through the filter. After these steps, you will see a change in the title. As in the first method, you can change the text - Leave your review to the one you like. This text is provided as an example.

I also want to suggest and pay attention to the declension of the word Comments. If you have a line in the form - 1 comment or Comments: 10 posted. You can use the Function from the article. If you are already using it, then I recommend in line with an array:

Array("comment","comments","comments")

Change the titles to review,review,reviews if you used that word in the methods above. thus, everything will be the same for you, and not in a scatter, there are reviews, and there are comments.

This is the information I would like to share with you today. Perhaps it will be useful to someone.

That's all, thanks for your attention. 🙂

It's been a while since I wrote anything about WordPress. Therefore, today I will share with you how you can manually change the comment form in WordPress. I think that this knowledge can be useful to any novice blogger, because the commenting form is, at times, the only means of communication between visitors and the author. Don't pass by :)

Before we start any manipulations with the code, I want to warn you in advance that we will edit the files of WordPress itself, and not the theme files. Yes, it may seem dangerous to someone, senseless to someone, someone just won't like it :) But I did it exactly like that and I didn't have any problems. I advise you to make a backup of the edited file before starting.
I warned you about security, now I want to show the result to which I came.


As we can see, the line “Your e-mail will not be published. Required fields are marked *". No need to consider visitors as brainless idiots. They understand what needs to be done and what doesn't. I also hid the field names inside the fields themselves. What are those fat posts? The majority of visitors already without field names can “by eye” determine which one belongs to what. But internal hints should still be present. Well, the caption to the comment field has lost its unnecessary boldness. In my opinion, it has become much better and freer.

So let's make a change soon! ;)
We go to the folder of our site and find the wp-includes/comment-template.php file in it. We are looking for the line 1522 in it, yes, yes, exactly it. How I found it myself is a whole story, I'll tell you about it a little later :)
So, open the file for editing and go to line 1522. Now she and the following (until 1529) are something like this:

$fields = array("author" => "

" . "" . ($req ? " *" : "") . "

", "email" => " ", "url" => "

" . "

",);

How simple and clear everything is. It is enough just to cut out everything superfluous and add a little. The parameter will be appended

Placeholder="(!LANG:Hint Text" !}

This option allows you to display any text inside the fields. We use it to display hints:

"

" "

" "

"

Let's delete the lines:

"

" . "" . ($req ? " *" : "") "

"

They are responsible for displaying the captions above the fields.
As a result of ALL these manipulations, we get the following:

$fields = array("author" => "

", "email" => "

", "url" => "

",);

It remains only to remove the stupid hint “Your e-mail will not be published. Required fields are marked *". To do this, delete the line (approximately 1537):

"comment_notes_before" => "

" .__("Your email address will not be published.") .($req ? $required_text: "") . "

",

That seems to be all, now our form has become a little more attractive. I hope this information is useful to someone :)

Subscribe, comment, I will be glad to any adequate comments. Maybe I don’t know something myself and you can do it differently, share your thoughts.

Hello dear readers, today I would like to talk with you on the topic commenting on articles. For many, especially young blogs, the problem of commenting on posts is acute. How to get the reader to write comments?

The author tries to write the material, the readers do not react at all. The author has the impression that he writes for nothing, and he ceases to like it. I have friends who gave up their hobby because of this.

Today I will reveal to you 8 secrets that will get your readers to comment on . Of course, I said highly, these are not secrets, but facts that many people forget about and suffer from it themselves. But before using these ways, don't forget to protect yourself from ;-).

How to force a visitor to write a comment?

It's simple, you just have to try a little to follow the rules I have described below, after which the number of comments on your site will slowly begin to grow. But this does not mean that you can use these chips stupidly and everything will be fine. You need to analyze what kind of visitors you have, what exactly they want and how to catch them, you can do this with the help of or 😉 Let's start ...

As a rule, readers do not comment because of fear: “What will they think of me? Suddenly I write the wrong thing and everyone will laugh ... ". You, as the author of the site, must make it clear to the reader that you are the same person as everyone else, that there is nothing to be afraid of ...

To do this, just create a page "" and write about yourself how you started, where you studied, where you live, and so on. The “Personal” section also works well, where from time to time you will write articles about yourself, for example, when you are in a funny situation, or.

Similar plugins also work very well - a plugin for displaying the last comments left. People will see that your site is being actively commented on and nothing bad is happening 😉

2) Motivate the reader to leave a comment.

Constantly ask the reader about something, ask questions, ask for their opinion. Then the reader will feel that you are really interested in his comments and will not leave you without attention. Many bloggers use this method:

They do not fully reveal the topic of the article, this is suitable for sites that write stories for the soul, but not for my subject. Therefore, I am against this method, it is better to write in detail and analyze the topic of the article, and at the end hint to readers that you can tell a little more, then the discussion will go 😉

3) Use contests and other incentives to comment.

Previously, so-called comment contests worked very, very well, where readers benefited from commenting on the site. Now this method works less efficiently, it’s all the fault of other FAT contests that are organized by popular bloggers with the help of sponsors such as Rookee, Seopult and so on ...

These contests have a budget of tens to hundreds of thousands of rubles, so you won’t surprise anyone with a comment contest with a prize of 500 rubles. And in this way you can push only those who love you and constantly read, but something was not enough for them to leave a comment .

Types of comment contests:

The most popular contest is the contest by the number of comments (). A contest is launched, and the most-most commentator is determined, who wrote the most comments for a certain period of time, and he is awarded an award, it is not uncommon for such contests to contain 3 prizes.

In addition to this competition, there are often those where, for example, the most informative comment is determined, or the best question asked to the author, for this you can use the rating system for the comment. The authors of these comments are happy, while others are waiting for a new similar contest to try again to get their penny

4) Comments that create controversy.

Try to constantly express your opinion, even if it goes against the public. Very often articles like why Android better ios are getting record numbers of comments because people are arguing. One of my articles is where I wrote why it's better and slightly humiliated other CMS systems.

I still get emails from people who ask me to try other CMS so that I can feel that they better wordpress. At that time, despite the fact that the article was one of the very first, and the blog was only about a week old, the article really got a record number of comments, if my memory serves me right

5) Always respond to every comment.

Do you not like it when you write an article, and readers do not comment on it? Likewise, the author of a comment that was left unanswered is unlikely to write comments again. Units of such authors who will finish you off until you answer. So don't offend your readers...

If possible, thank the reader for the comment (possibly for the first comment) and answer his question in as much detail as possible, agitate to ask more, promise that you are always ready to answer any comments, and keep the promise. Then readers will feel that they are interested in them and will not leave you without attention ....

7) Comment on other blogs.

It may seem ridiculous, but it still works. If you leave interesting comments on other sites, not only can it raise your authority, the authority of the site, and even bring new visitors to the site. There are several examples where, with the help of one comment, bloggers got themselves a mountain of new visitors…

But for this you need to write really strong, interesting and informative comments. They should hurt not only the readers of the blog on which you left comments, but also the author of this site. But if you succeed, consider that you have killed a big score.

8) Leave a comment with the same name and with the same avatar.

It is very important! Whether it's if you leave comments on your site, or on someone else's, always do it only with the same nickname and avatar. How to use the same avatar I wrote here. Why do you need to do this?

See you soon, your obedient servant Albert and blog ...

Liked the article? Share with friends!
Was this article helpful?
Yes
Not
Thanks for your feedback!
Something went wrong and your vote was not counted.
Thank you. Your message has been sent
Did you find an error in the text?
Select it, click Ctrl+Enter and we'll fix it!