WordPress.org

Ready to get started?Download WordPress

Forums

Enable HTML including <.div>, <.p>, and <.img> in Category Descriptions (9 posts)

  1. datasta
    Member
    Posted 6 years ago #

    Hey,

    In wordpress 2.3, How can I enable the ability to use HTML in my category descriptions? I notice I'm able to include links, but if I try to pull an image in, it won't work.

    Is tehre any way to enable this?

  2. datasta
    Member
    Posted 6 years ago #

    bump... anyone know?

  3. syncbox
    Member
    Posted 6 years ago #

    yes... in:

    /wp-includes/default-filters.php around line #60 (at least, in v2.2x) look for:

    //add_filter('pre_category_description', 'wp_filter_kses');

    the // I put in front disables the filter from removing html tags and such in category_description

    HTH

  4. datasta
    Member
    Posted 6 years ago #

    Hey Sync..

    In 2.3, that line doesn't exist. I looked. Was it changed to something else?

  5. syncbox
    Member
    Posted 6 years ago #

    well, I've not upgraded because of the horrific "everything stops working" posts I'm seeing in the forum...

    1) maybe they are allowing html in the category description now (not filtering)
    2) Maybe you just aren't calling the image properly so it simply doesn't display?
    3) does the link reference stay in the content of the description and the html to display the image is removed when you revisit that category via Manage>Category by clicking the Edit link?

    I guess I'm asking if you think it's not working because it actually removes what you put in the category description FIELD or you think it isn't working because the image doesn't show up.

    Just trying to help. Stripping of HTML in 2.2x annoyed the hell out of me until I fixed it using my suggestion above. As I said, I've been reluctant to upgrade just due to large number of wtf? posts about 2.3

  6. datasta
    Member
    Posted 6 years ago #

    If I add in a Category description using HTML it removes all html, like <img src and div tags, but it leaves in the URL stuff like a href

  7. datasta
    Member
    Posted 6 years ago #

    Does anyone else know anything about this?

  8. datasta
    Member
    Posted 6 years ago #

    I guess this will be my last chance to figure this out.

    If anyone could tell me how to display full on HTML in a category description in wordpress 2.3 it would be greatly appreciated.

    Thanks!

  9. FireDollJamie
    Member
    Posted 6 years ago #

    The post above is still accurate as far as the file goes, but the content has changed a bit for 2.3. You're looking for this section around line 14:

    // Kses only for textarea saves

    $filters = array('pre_term_description', 'pre_link_description', 'pre_link_notes', 'pre_user_description');
    foreach ( $filters as $filter ) {
    	add_filter($filter, 'wp_filter_kses');
    }

    Comment out the add_filter line and you're set.

    Alternatively, you could create a category template for that specific category, get the text content of the description out via:
    <?php echo category_description($cat);
    and put your images in your category template.

Topic Closed

This topic has been closed to new replies.

About this Topic