我需要在此页面上的每个锚点上添加一个“project-img”类:http: //petekingston.com/portfolio/test/
我的这个 atm 的代码(PHP 循环)是:
<div id="container">
<?php foreach (simple_portfolio_media() as $media_item): ?>
<div class="box lightGrey masonry masonry-brick">
<?php
$class = ('') ? 'class="project-img"' : '';
switch ($media_item['type']):
case 'image':
$src = wp_get_attachment_image_src($media_item['value'], 'full');
echo "<a $class href=\"$src[0]\">" . wp_get_attachment_image($media_item['value']) . "</a>";
break;
case 'youtube':
echo "<p>";
echo "<object width=\"480\" height=\"385\">";
echo " <param name=\"movie\" value=\"http://www.youtube.com/" . $media_item['value'] . "&hl=en_US&fs=1\"/>";
echo " <param name=\"allowFullScreen\" value=\"true\"/>";
echo " <param name=\"allowscriptaccess\" value=\"always\"/>";
echo " <embed src=\"http://www.youtube.com/v/" . $media_item['value'] . "&hl=en_US&fs=1\" type=\"application/x-shockwave-flash\" allowscriptaccess=\"always\" allowfullscreen=\"true\" width=\"480\" height=\"385\"/>";
echo "</object>";
echo "</p>";
break;
case 'snippet':
echo $media_item['value'];
break;
endswitch;
?>
</div><!-- END box -->
<?php endforeach; ?>
</div><!-- END container -->
但是,它不会将类添加到锚点。任何帮助将非常感激。
先感谢您!
皮特