Only display items on front page (WordPress)

Sorry for the awful title, I couldn’t think of anything better.

Basically I have this code:

Read More
<div id="slideshow-side-tab">
    <img src="<?php bloginfo('template_directory'); ?>/images/bg-slideshow.png"/>
        <div id="slideshow">
            <img src="<?php bloginfo('template_directory'); ?>/images/slideshow/image-1.jpg" alt="" class="active" />
            <img src="<?php bloginfo('template_directory'); ?>/images/slideshow/image-2.jpg" alt="" />
            <img src="<?php bloginfo('template_directory'); ?>/images/slideshow/image-3.jpg" alt="" />
            <img src="<?php bloginfo('template_directory'); ?>/images/slideshow/image-4.jpg" alt="" />
        </div>
</div>

However I only want this to display when the user is on the front page of WordPress. The homepage has been set to a static page created from within wordpress and I can’t just copy this code into the page as it only accepts HTML in the page editor. How can I make this happen?

I have had a look on WordPress and I found this:

<?php
if (is_home()) {
    // This is a homepage
} else {
    // This is not a homepage
}
?>

But that doesn’t seem to work if I place my code in place of the ‘// This is a homepage’.

Any help would be appreciated. Thanks.

Related posts

Leave a Reply

2 comments

  1. Try with:

    <?php if (is_front_page()) { ?>
    
    <div id="slideshow-side-tab">
        <img src="<?php bloginfo('template_directory'); ?>/images/bg-slideshow.png"/>
            <div id="slideshow">
                <img src="<?php bloginfo('template_directory'); ?>/images/slideshow/image-1.jpg" alt="" class="active" />
                <img src="<?php bloginfo('template_directory'); ?>/images/slideshow/image-2.jpg" alt="" />
                <img src="<?php bloginfo('template_directory'); ?>/images/slideshow/image-3.jpg" alt="" />
                <img src="<?php bloginfo('template_directory'); ?>/images/slideshow/image-4.jpg" alt="" />
            </div>
    </div>
    
    <?php } ?>