Jump to content

Loading image dependent on category


bigbrennan

Recommended Posts

I have posted this on the WordPress forum and have had no joy, could anyone here offer some advice?

 

Hi guys,

 

We have created a small PHP script which will load a particular image dependent on which category the blog is posted in.

 

On our website index (index.php) we have the following codes:

 

Header:

 

<?php

require('blog/wp-blog-header.php');

?>

 

Body:

 

<?php

if(get_the_category_list(', ')=="john-virgo")
{
    ?>
                              <img src="images/top5.jpg" width="100" height="100" alt="" />
                              <?php
}
elseif(get_the_category_list(', ')=="something")
{
    ?>
                              <img src="image2.jpg" width="100" height="100" alt="" />
                              <?php
}

?>

 

But this is not working correctly.

 

If I set the criteria to be 'uncategorized' then it will load the image, but any other category title and it won't.

 

Any ideas?

Link to comment
https://forums.phpfreaks.com/topic/63866-loading-image-dependent-on-category/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.