• Is it possible to allow HTML to be rendered in Category descriptions? My theme uses them quite a lot, and I’d like to style them better with images and links.

    This seems to be do-able from what I read elsewhere, but I wondered if there is a best practice to get it to work (I’d prefer not to use a barely supported plugin).

    Many thanks,

    R

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter rjt1985

    (@rjt1985)

    Update:

    I have used a bit of code from WooCommerce / WordPress Stack Exchange to allow HTML to be used and shown in the category description (so I can format it a little bit, and add images).

    The code is as follows…

    foreach ( array( 'pre_term_description' ) as $filter ) {
        remove_filter( $filter, 'wp_filter_kses' );
    }
    
    foreach ( array( 'term_description' ) as $filter ) {
        remove_filter( $filter, 'wp_kses_data' );
    }

    …which I put in my functions file.

    It works! (to an extent)

    I can now add HTML to my category descriptions such as an image, or a link (see here: https://dev.rjthompsonmusic.com/category/music/the-cognitive-rules-ep/).

    However, it still won’t let me put paragraphs or page breaks in (br and p) so all the text still seems to appear in one block. Any idea why this would be… if there’s a clash with your code or something extra I need to do?

    Many thanks,

    R

    when using a break or paragraph, be sure to close the tag:

    <p />

    oops.. forgot to put it in the code box…

    <br /> and <p />

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Category Descriptions – HTML?’ is closed to new replies.