Forums

category images using category description (3 posts)

  1. vachi
    Member
    Posted 8 months ago #

    i have been trying to display category image by putting a image link in the category description area than calling the category description inside a img tag as the image src

    now this does not work here is my code

    <?php foreach(get_the_category() as $category)
    			{ $thecat = $category->cat_ID; } ?>
    
    			<?php $catImage = category_description($thecat); ?>
    			<?php echo $catImage ?>
    
    			<img src="<?php echo $catImage ?>" />

    now <?php echo $catImage ?> this displays the category description text

    but the image does not show because wordpress is putting some weird things in the call

    any solutions or suggestions are greatly welcome
    i am thankful in advance

  2. Chris_K
    Administrator
    Posted 8 months ago #

    Does this plugin do what you're after?
    http://wordpress.org/extend/plugins/category-icons/

    If so, you could either use it or examine code to get a feel for how he does it?

  3. vachi
    Member
    Posted 8 months ago #

    tx for the reply, yeah i looked at that plugin before, i am more after displaying the category image in single.php

    the problem with the current code i have is that the img source comes out to be this
    http://blah.com/blog/post-name/%3Cp%3Ehttp://blah.com/blog/files/2009/03/image.png%3C/p%3E

    so it adds these p%3E to the beginning and end of the text and on top of that ads the post link at the beginning

    example where i am using it
    http://vitamovie.com/anime/eureka-seven-episode-50/

    i really want to find a non plugin solution where i can just use the given wordpress category description field

Reply

You must log in to post.

About this Topic