Where do i put an is_home( ) php line?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
batesy
Forum Newbie
Posts: 1
Joined: Mon Aug 24, 2009 1:10 am

Where do i put an is_home( ) php line?

Post 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');
User avatar
arminium
Forum Newbie
Posts: 18
Joined: Wed Aug 12, 2009 10:02 pm
Location: Sunshine Coast, AUSTRALIA!!!!!!

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

Post 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
}
 
Post Reply