錨我需要一個類的項目IMG「添加到每個錨此頁上:http://petekingston.com/portfolio/test/PHP - 添加類環
我的代碼(PHP環),該ATM是:
<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 -->
但是,它不會將類添加到錨。任何幫助將非常感激。
預先感謝您!
皮特
什麼是$ class =('')? 'class =「project-img」':''; ?它正在檢查什麼是空字符串? –
我很不幸與PHP並沒有試圖從這裏合併代碼:http://stackoverflow.com/questions/2913415/how-add-class-active-to-html-menu-with-php –