treehouse : what would you like to learn today?
Web Design Web Development iOS Development

WordPress - category image

  • I have modified the categories.php and loop.php to display only the title of each post in my theme with the permalink. I have added an image field to the categories admin area so that when you make a new category, you can upload an image for that category. I am making a menu for a restaurant. So I will make a lunch category, upload a featured image for that category and then post several posts to that category that will display the title under the featured image. When you click on the title, it will take you to the post.

    I have this sort of working. I can get the featured image for the category by doing this

    $cat_image = get_option('category_image'); 
    <img src="<?php echo $cat_image[7][image];?>">
    

    The problem with that is that I need to be able to get the image without getting it by name. There are going to be many categories and I won't know each specific ID. got any idea how to get it out of the array it stored in the dateabase?