如何在标记内放置foreach循环?
这是代码:
Button
我一直收到错误。你能帮我使用PROPER语法吗?
答案 0 :(得分:2)
foreach( $designer_posts as $designer_post ) {
$tags = get_the_tags($designer_post->ID);
$imageThumb = get_the_post_thumbnail( $designer_post->ID, "thumbnail" );
$html .= '<tr>';
$html .= '<th scope="row">View</th>';
$html .= '<td><p>'.$designer_post->post_title.'</p></td>';
$html .= '<td>';
foreach() {
$html .= 'The rest of the HTML code';
}
$html .= '</td>';
$html .= '<td>'.$imageThumb.'</td>';
$html .= '</tr>';
}
答案 1 :(得分:1)
我想你想这样做:
foreach( $designer_posts as $designer_post ) {
$tags = get_the_tags($designer_post->ID);
$imageThumb = get_the_post_thumbnail( $designer_post->ID, "thumbnail" );
$html .= '<tr>';
$html .= '<th scope="row">View</th>';
$html .= '<td><p>'.$designer_post->post_title.'</p></td>';
$html .= '<td>';
foreach($designer_post as $test) {
$html .= 'what you want fraté';
}
$html .= '</td>';
$html .= '<td>'.$imageThumb.'</td>';
$html .= '</tr>';
}
答案 2 :(得分:0)
<?php
foreach( $designer_posts as $designer_post ) {
$tags = get_the_tags($designer_post->ID);
$imageThumb = get_the_post_thumbnail($designer_post->ID,"thumbnail");
?>
<tr>
<th scope="row">View</th>
<td><p> <?php print $designer_post->post_title; ?></p></td>
<td>
<?php foreach($array_data as $data) {
print $data;
} ?>
</td>
<td> <?php print $imageThumb; ?></td>
</tr>
<?php } ?>