Page 1 of 1

Where do i put an is_home( ) php line?

Posted: Mon Aug 24, 2009 1:12 am
by batesy
Okay... I'm no coder, so here goes...

I have a rotating image carousel-type thingy on a wordpress blog that I load customized feature images into.

My problem is that I have this sucker repeating on every page above the post.

I really need it to load only on the homepage.

I've tried putting a is_home () tag in the code, but I really don't know where it is supposed to go!! :confused:


Here's the code... any help much appreciated.

Cheers
/* ------------ Rotating images top page ------------ */
function top_feature_box_rotator() {
echo ' <div class="adblock"><center>';

/*Rotating Ad number 1*/
$ads = array(array("title"=>"feature_box_1",
"img" =>"http://mysite.com/wp-content/themes/the ... image1.jpg",
"url" =>"http://www.url.com",),

/*Rotating Ad number 2*/
array("title"=>"feature_box_2",
"img" =>"http://mysite.com/wp-content/themes/the ... image2.jpg",
"url" =>"http://www.url.com",),

/*Rotating Ad number 3*/
array("title"=>"feature_box_3",
"img" =>"http://mysite.com/wp-content/themes/the ... image3.jpg",
"url" =>"http://www.url.com",)
);
shuffle($ads);
$ads = array($ads[0],$ads[1],$ads[2]);

foreach($ads as $ad){
?>
<a href="<?=$ad["url"]?>"><img src="<?=$ad["img"]?>" alt="<?=$ad["title"]?>" border="0"/></a>
<?
}
echo ' </div></center>';
}
add_action('thesis_hook_before_content', 'top_feature_box_rotator');

Re: Where do i put an is_home( ) php line?

Posted: Mon Aug 24, 2009 2:43 pm
by arminium
I am not familiar with word press or the is_home() function, but have your tried wrapping the banner function in a if statement

Code: Select all

if(is_home()){
///banner code here
}
 
depending on what the output of is_home function you might need to add a condition to it, like

!= does not equal
== is equal to

Code: Select all

if(is_home() == true){
///banner code here
}