Where is comment form
You can learn quite a bit of code organization techniques and coding tricks from them. It is a good practice to steal the code from the default themes And, sometimes you have to steal quite a bit of code from them for your custom theme. Now the comment form is getting outputted without any notice or errors!
Pin Great! There is a problem. Can you guess which function it is? You have sharp eyes. I tried calling this function outside the array and PHP threw a fatal error. And, once we find such a function, we have two options: Search for the function definition inside the default theme and copy it in our theme as well. This will solve our problem.
Here is the updated code from comments. Pin If you viewing the same comment form after logging out, you have to fill out the other fields too. Pin Now post at least four comments and give reply to a couple of them by using a different name. I went ahead and created and some comments and everything is working fine in my testing!
Pin If you notice, there are four approved comments and one comment is waiting for moderation. Pin We are now done with the title of the comment.
You can learn more about this function by visiting the following URL. Comment list depends on Gravatar service too Also, if you notice the above screenshot, a dummy image is being used for the avatar. This thing is that WordPress depends on Gravatar service for comment author avatars as well.
You can customize the way WordPress handles content as well as comments. You might want them to say whether they liked your blog post. You could have any one of thousands of reasons for adding input fields to the comment form on your WordPress website.
So, how do you extend the WordPress comment form with a custom input field? In this article, we will add three input fields to the comment form of a WordPress website: two text-input fields for a phone number and comment title and a radio option for rating the current article.
And we will use many more functions to achieve the desired result. We can extend the comment form by editing the theme or by creating a theme that alters the behavior of the active theme to include the additional input fields.
Modifying the theme is relatively easier to do, but it has an obvious limitation: all the effort that has gone into customization will be for nought if the theme is replaced. Using a plugin to customize the comment form frees us from this limitation. This way, the customized comment form will apply to all themes except those that have non-standard methods for adding the comment form.
Make sure to save it in a folder of the same name, ExtendComment, to keep the organization of files simple. The headers are pretty much self-explanatory:. Now, we need to start actually adding the input fields.
The default fields are for name, email address and website URL. This set of input fields is hidden if the user is logged in. Retrieves the full permalink for the current post or post ID. Calls the callback functions that have been added to an action hook. Calls the callback functions that have been added to a filter hook. Filters the content of the comment textarea field for display.
Fires before the comment fields in the comment form, excluding the textarea. Fires after the comment fields in the comment form, excluding the textarea.
Fires at the bottom of the comment form, inside the closing form tag. Asked 9 years, 4 months ago. Active 11 months ago. Viewed 47k times. Improve this question. Matthias 10k 7 7 gold badges 35 35 silver badges 53 53 bronze badges. The biggest ones I absolutely need to tweak are numbers 1, 2, 5 and 6 in my above list. Add a comment. Active Oldest Votes. Improve this answer. Simple example how to change some comment form fields.