WordPress.org

Ready to get started?Download WordPress

Forums

2.9 strips img tags from description (7 posts)

  1. sshilo
    Member
    Posted 4 years ago #

    I use the category description in my theme.

    Since the upgrade to 2.9, image tags are stripped from the description (when using category_description();)

    any suggestions?

    Now, I use the "Category Description Editor" plugin, and when I go to edit the category, I can see the image in the editor. So, it's being saved in the db, but not being included in the function above.

    is there a new function?

  2. Kevin Leary
    Member
    Posted 4 years ago #

    I too am having the same issue with the Rich Text Tags plugin (http://wordpress.org/extend/plugins/rich-text-tags/). Began right after the upgrade to 2.9.

  3. Kevin Leary
    Member
    Posted 4 years ago #

    sshilo, I actually found a fix for this. It's not most elegant setup, I'm no PHP expert, but it works.

    <?php // Get current category ID on category page
    function getCurrentCatID(){
    	global $wp_query;
    	if(is_category() || is_single()){
    		$cat_ID = get_query_var('cat');
    	}
    	return $cat_ID;
    }
    $currentCat = getCurrentCatID();
    // Loop through all categories with the rich text descriptions, and display the category description for the current category
    $explorers = get_categories('hide_empty=0&child_of=13');
    foreach ($explorers as $cat) {
    	if($cat->cat_ID == $currentCat) {
    		if ($cat->category_description != '') {
    			echo '<div class="category-desc-entry clearfix">'.$cat->category_description.'</div>';
    		} else {
    			echo '<div class="category-desc-entry clearfix"><p>No description has been entered for this explorers. <a href="'.wp_login_url().'">Log in</a> and go to <strong>Posts > Categories</strong> to add descriptions.</p></div>';
    		}
    	}
    } ?>

    I used this to display the category description on a category page. It seems that if you call the category description from a get_categories loop, using ->category_description it will include images. I'm sure there's a way to take this and rewrite the category_description() function; but I'll leave that up to a more seasoned programmer.

    I hope this helps.

  4. jlee85
    Member
    Posted 4 years ago #

    I have the same problem. Please someone help. What are we suppose to do to make it work again?

  5. landun
    Member
    Posted 4 years ago #

    There are two problems:

    1. If you want to display images in your category descriptions you have to replace category_description() in your theme with:

    $category = get_the_category();
    echo $category[0]->category_description;

    2. If you want to add or update category descriptions with images using 2.9 you have to edit the database manually. It seems the admin interface is stripping images before saving to the database.
    If you can use phpMyAdmin or similar try this SQL to get the relevant posts.
    SELECT * FROM wp_term_taxonomy WHERE taxonomy = 'category';

    Today I hate wordpress.

  6. Samuel Wood (Otto)
    Tech Ninja
    Posted 4 years ago #

    That was intentional, for several reasons. Mainly for security purposes.

    See these:
    http://core.trac.wordpress.org/ticket/9753
    http://core.trac.wordpress.org/ticket/10751

  7. murphyca
    Member
    Posted 4 years ago #

    @landun

    Thank you. That worked for me~

    <?php $category = get_the_category(); ?>
    echo $category[0]->category_description;

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.