page title in image alt tag
Posted: Thu May 16, 2019 6:13 pm
I have a set of banner images that I am using in the header and would like the page title to be listed in the alt tag. However, what is being listed is the php code instead of the page title. Is there a way to do this? This is what I have:
Code: Select all
<?php
$banner1 = '<a href="https://plexusworldwide.com/essentialsoflife/home" target="_blank"><img class="aligncenter" src="http://cdn.essentialsoflife.net/bludit-test/bl-themes/plexathon/img/slim-01.jpg" alt="<?php echo $page->title(); ?>"></a>';
$banner2 = '<a href="https://plexusworldwide.com/essentialsoflife/home" target="_blank"><img class="aligncenter" src="http://cdn.essentialsoflife.net/bludit-test/bl-themes/plexathon/img/slim-02.jpg" alt="<?php echo $page->title(); ?>"></a>';
$banner3 = '<a href="https://plexusworldwide.com/essentialsoflife/home" target="_blank"><img class="aligncenter" src="http://cdn.essentialsoflife.net/bludit-test/bl-themes/plexathon/img/slim-03.jpg" alt="<?php echo $page->title(); ?>"></a>';
$banners = array($banner1, $banner2, $banner3);
shuffle($banners);
?>
<div>
<?php echo $banners[0] ?>
</div>