how to get a div to only show on home page?

kaos092

New member
May 29, 2011
41
0
0
how would i go about making this div only appear on the home page?

function my_div() {
?>
<div id="left" style="left: 10px; top: 10px; width: 984px; height: 100px; background: black;">
</div>
<?php
}
add_action('thesis_hook_after_header' , 'my_div');
 


Never used thesis, so don't know about the hooks. But, You could just stick this in where you want it.

Code:
<?php
// If Homepage
if ( is_home() ) {
//Show Your shit here
    echo '<div id="left" style="left: 10px; top: 10px; width: 984px; height: 100px; background: black;">
</div>';
}
?>
 
Never used thesis, so don't know about the hooks. But, You could just stick this in where you want it.

Code:
<?php
// If Homepage
if ( is_home() ) {
//Show Your shit here
    echo '<div id="left" style="left: 10px; top: 10px; width: 984px; height: 100px; background: black;">
</div>';
}
?>

thank you sir

i know how to use the hooks so i'm good thanks
 
A little easier method, you could do it with only css, if you don't mind just hiding the div instead of removing it altogether. Wordpress adds a class of "home" to the body tag of the homepage. So you could do it like this:

Code:
.your-div-class { display: none; }
.home .your-div-class { display: block; }