bigbrennan Posted August 2, 2007 Share Posted August 2, 2007 Hi guys, stumbled across the site whilst looking for help! I am using wordpress blog, and have used the following to get the latest blog title + category to display: Head - <?php require('blog/wp-blog-header.php');?> Body - <?php if (have_posts()) : ?> <?php while (have_posts()) : the_post(); ?> <div class="post" id="post-<?php the_ID(); ?>"> <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"> <?php the_title(); ?> </a></h2> <small> <!-- by <?php the_author() ?> --> </small> <p class="postmetadata"> <?php the_category(', ')?> </p> </div> <?php endwhile; ?> <div class="navigation"> <div class="alignleft"> <?php next_posts_link('« Previous Entries') ?> </div> <div class="alignright"> <?php previous_posts_link('Next Entries »') ?> </div> </div> <?php else : ?> <h2 class="center">Not Found</h2> <p class="center">Sorry, but you are looking for something that isn't here.</p> <?php include (TEMPLATEPATH . "/searchform.php"); ?> <?php endif; ?> Now what I want to happen is it to display an image dependent on what category it is. I tried this: <?php if($var_the_category=="Uncategorized"){ echo "<img src=\"images\top2.jpg" alt=\"\" />"; } elseif($var_the_category=="name2"){ echo "<img src=\"image2.jpg\" alt=\"\" />"; } elseif($var_the_category=="name3"){ echo "<img src=\"image3.jpg\" alt=\"\" />"; } ?> But something is not working.... could some care to explain where I have gone wrong? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/63055-getting-an-image-to-display-if-a-field-something/ Share on other sites More sharing options...
deadimp Posted August 2, 2007 Share Posted August 2, 2007 Your code looks like you come from ColdFusion or something... What exactly are your errors when trying to show the image according to category? Quote Link to comment https://forums.phpfreaks.com/topic/63055-getting-an-image-to-display-if-a-field-something/#findComment-314290 Share on other sites More sharing options...
soycharliente Posted August 2, 2007 Share Posted August 2, 2007 There are support forums specifically for WP. Did you try there? Quote Link to comment https://forums.phpfreaks.com/topic/63055-getting-an-image-to-display-if-a-field-something/#findComment-314291 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.