Reputation: 8457
I want icon-backtotop.png
to appear only on the home page and icon-backtotop-alt.png
to appear on all other pages. However, with the code below, icon-backtotop-alt.png
shows on all pages. How can I fix this code?
<?php if (is_home()) { ?>
<img src="<?php echo get_stylesheet_directory_uri(); ?>/img/icon-backtotop.png" alt="Back To Top" />
<?php } else { ?>
<img src="<?php echo get_stylesheet_directory_uri(); ?>/img/icon-backtotop-alt.png" alt="Back To Top" />
<?php } ?>
Upvotes: 2
Views: 4108
Reputation: 7505
you probably want to use is_front_page not is_home
Note: WordPress 2.1 handles this function differently than prior versions - See static Front Page. If you select a static Page as your frontpage (see is_front_page()), this tag will be applied to your "posts page".
try
<?php if (is_front_page()) { ?>
<img src="<?php echo get_stylesheet_directory_uri(); ?>/img/icon-backtotop.png" alt="Back To Top" />
<?php } else { ?>
<img src="<?php echo get_stylesheet_directory_uri(); ?>/img/icon-backtotop-alt.png" alt="Back To Top" />
<?php } ?>
Upvotes: 4