【发布时间】:2012-02-05 02:57:27
【问题描述】:
我有一个 Wordpress 网站,并且我有一个画廊,其中列出了每个项目的图片和网址。但是我似乎无法结合 foreach 语句。我总是出错。我知道我很接近,我想我只需要重新安排一下。谢谢!
<?php
foreach($latest_projects as $post) : setup_postdata($post);
//get image
$recent_project_thumb = wp_get_attachment_image_src(get_post_thumbnail_id(), 'recent-work');
foreach ($categories as $cat ) :
//get image
$categories = get_terms('gallery_cats');
?>
<li><a href="https://website.com/<?php echo $cat->slug; ?>"><img src="<?php echo $recent_project_thumb[0]; ?>" alt="<?php the_title(); ?>" width="162" height="100" class="imgstyle" /></a></li>
<?php endforeach; ?>
【问题讨论】: