TransWikia.com

How to enable HTML tags in category description without breaking the category page

WordPress Development Asked by Thredolsen on October 30, 2021

I’m trying to include hyperlinks as part of the description on a category page.

Since WordPress strips the necessary HTML tags, I’ve added the following PHP code in a plugin, which stops the HTML tags from getting stripped:

add_action('init','disable_kses');

function disable_kses() {
    remove_filter('pre_term_description', 'wp_filter_kses');
    }

This lets me include HTML tags fine, but when I include a hyperlink in the description, it breaks the page in a weird way, with material from the description being reproduced above the header. This includes all the text from the first hyperlink until the end of the description, but the first link itself isn’t reproduced (only the text for it is). In addition, at the very end of the material, the following is appended to the text:

">

So the end result (in terms of the material that appears above the header) looks like this:

enter image description here

Other than that, in the place where the description should appear (under the title), everything renders properly, including the hyperlinks, so that it looks like this:

enter image description here

The HTML that I use to include the hyperlinks is standard:

<a href="http://example.org/">example</a>

I have also tried similar solutions, such as the "HTML in Category Descriptions" plugin, and the following code, which addresses the other filters that are at play here, but nothing works:

add_action('init','disable_kses');
function disable_kses() {
    foreach (array('pre_term_description', 'pre_link_description', 'pre_link_notes', 'pre_user_description') as $filter) {
            remove_filter($filter, 'wp_filter_kses');
        }
    }

My question is what should I be doing differently in order to be able to include hyperlinks as part of the category page description?

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP