开发者

How to add image alt and title tags to wordpress images

I'm trying to add an image alt and title text to each imag开发者_运维百科e in an image gallery in wordpress but can't seem to make it work. Here's my code:

<?php 

$events = get_group('Gallery');
foreach($events as $event){  

for($i=1;$i<4;$i++) {
if(empty($event['gallery_gallery_image_'.$i])) 
  continue
  ;
$image = $event['gallery_gallery_image_'.$i];
?>

<a href="<?php  echo $image[1]['o']; ?>"><img src="<?php echo $image[1]['t']; ?>" /></a>

<?php } }?>

any help would be much appreciated


do you want to add them as static or dynamic ?

if it's static just add it after the tag

<img alt='xyz' title='abc' src="<?php echo $image[1]['t']; ?>

if not , just add the dynamic variable name like you did in your echo $image..

<a title="<?php  echo $image[1]['title']; ?>" href="<?php  echo $image[1]['o']; ?>"><img alt="<?php  echo $image[1]['alt']; ?>" src="<?php echo $image[1]['t']; ?>" /></a>

change $image[1]['alt'] && $image[1]['title']; (title & alt are the name of ur variables)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜