How to disable HTML in WordPress comments
Apr 20, 2025 am 07:15 AMBy default, WordPress allows certain HTML tags to be included in comments, such as etc. If you find a lot of spam, these tags are included. Most spam comments are sent by bots and scripts that use HTML tags. If you just disable HTML in WordPress comments, you can prevent a lot of spam. In this tutorial, we will show you how to disable HTML tags in WordPress comments.
This tutorial will disable only the active HTML tags. So someone can still post something like this:
It will show up, but the tags won't work. So if someone uses strong markup it won't bold the text. Also, not many spam bots have time to do this, as this method takes up a lot of time and does not benefit them.
All you have to do is open your functions.php and add the following code:
// This will occur when the comment is posted functionplc_comment_post( $incoming_comment) { // convert everything in a comment to display literally $incoming_comment['comment_content'] = htmlspecialchars($incoming_comment['comment_content']); // the one exception is single quotes, which cannot be #039; because WordPress marks it as spam $incoming_comment['comment_content'] = str_replace( "'", ''', $incoming_comment['comment_content'] ); return( $incoming_comment); } // This will occur before a comment is displayed functionplc_comment_display( $comment_to_display) { // Put the single quotes back in $comment_to_display= str_replace( ''', "'", $comment_to_display); return$comment_to_display;}
Depend on
Use it with one click in WordPress
If you don't want to add this code manually yourself, the original author also provides a plugin that you can download. Just install and activate Peter's text comment plugin.
This method is better because it doesn't require you to change the core files. If you want to edit the core file, then you can go to wp-includes/kses.php and edit the code there. (This is not recommended, but here is for knowledge. (WP Codex for more details)
The above is the detailed content of How to disable HTML in WordPress comments. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

As an important digital asset hard forked from the original Ethereum blockchain, Ethereum Classic (ETC) has always been the focus of market attention. After experiencing ups and downs in early development and multiple technological iterations, ETC still occupies a place in the global cryptocurrency market with its unique decentralized spirit and smart contract platform functions. There are many factors that affect ETC prices, including but not limited to macro trends in the entire cryptocurrency market, ETC’s own network upgrades and security, community activity, changes in regulatory environments, and the attitudes of institutional investors.

The latest version of Digital Currency Exchange 2025 is a world-leading digital asset trading application, committed to providing users with secure, stable and convenient trading services for mainstream digital currencies such as Bitcoin and Ethereum. Its simple and intuitive operation interface and powerful functional modules make it easy for both novices and senior traders to get started.

Ethereum, as one of the blockchain platforms with leading market value and the most active ecosystem, has attracted much attention. It is not only a digital asset, but also the cornerstone of innovation fields such as decentralized applications, smart contracts, decentralized finance (DeFi) and non-fungible tokens (NFT). Predicting its future price trend is a complex process, affected by the interweaving of multiple factors such as technological development, macroeconomic environment, regulatory policies, market sentiment and network itself upgrade.

Dogecoin (DOGE), a digital asset originating from the Internet subculture, has occupied a place in the crypto market with its unique community culture and wide popularity. For many market participants, predicting their price movements over a specific time period in the future is challenging but attractive. This article aims to deeply analyze the key factors that may affect Dogecoin’s market value from 2025 to 2030 and explore its potential development path.

The latest version of Binance is v2.102.5, and the update tutorial is: 1. Click the download link in the web page; 2. Authorize the installation permission of "Allow installation from unknown sources"; 3. Find the downloaded APk and click to install; 4. Click the installed application to open it.

The latest version of Binance is v2.102.5, and the update tutorial is: 1. Click the download link in the web page; 2. Authorize the installation permission of "Allow installation from unknown sources"; 3. Find the downloaded APk and click to install; 4. Click the installed application to open it.

The three types of cryptocurrencies that may be liquidated or restricted by regulators in 2025 include: 1. Privacy currency, which is easily used for illegal activities due to its anonymity and faces restrictions or removal from the shelves caused by the strengthening of global AML/KYC regulations; 2. Unregistered securities tokens may be removed from the exchange or required rectification due to non-compliance with securities regulations; 3. Non-compliant stablecoins may be prohibited from trading due to lack of transparent reserves or regulatory permissions. It is recommended to pay close attention to regulatory trends, diversified investment, pay attention to exchange announcements and consult professionals to deal with policy risks.

The latest version of Binance is 2.101.8, and the update tutorial is: 1. Click the download link in the web page; 2. Authorize the installation permission of "Allow installation from unknown sources"; 3. Find the downloaded APk and click to install; 4. Click the installed application to open it.
