V
V
vvvadimos2018-04-20 11:06:38
WordPress
vvvadimos, 2018-04-20 11:06:38

How to programmatically disable comments in Wordpress?

you need a code that will completely block comments on the site. they are disabled through the admin panel, but it’s still possible to somehow send them through requests, past the forms. without plugins

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Igor Vorotnev, 2018-04-20
@vvvadimos

without plugins

It always makes me smile when people write this phrase...
Plugins in WP are just pieces of code. The same code in a plugin or in functions.php does exactly the same thing. The only exception is if the plugin still provides a settings page, and you don't need it - then download the plugin, open the code and copy exactly what you need from there. In general, the question is not whether to use the plugin or not, the question is solely how good its code is. The same applies to "code in functions.php" - you can also cram some kind of nastiness there.
And now specifically on the issue of comments: Install the Disable Comments plugin and close the issue once and for all.
If an extra plugin in the list directly interferes, open its code, delete everything superfluous, copy the rest to where it is more convenient for you and use it in this form. But I don’t see any point in this at all (and I’m a fan of performance and cutting out unnecessary code), in this case the plugin solves the issue as efficiently as possible.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question