因此,我希望能够在下面的foreach语句的末尾包含使用html标签的<p></p>
,但是我仍然遇到代码问题。
代码:
<?php if(!empty($mediaUrls)):
if(is_front_page() || is_home()):
$counter = 0;
foreach($mediaUrls as $entry):
$counter++;
$mediaurl = $entry['media_url'];
$permalink = $entry['permalink'];
if($counter > 6) {
break;
}
?>
<article class="tw-status">
<div class="tw-content">
<a href="<?= $permalink; ?>" target="_blank"><img alt="" class="insta_image" src="<?= $mediaurl; ?>" width="100%"/></a>
</div>
</article>
<?php endforeach;
endif;
else:
echo 'No posts available.';
endif;
?>
答案 0 :(得分:0)
您需要先关闭PHP
,然后才能添加P
标签,如下所示:
<?php if(!empty($mediaUrls)):
if(is_front_page() || is_home()):
$counter = 0;
foreach($mediaUrls as $entry):
$counter++;
$mediaurl = $entry['media_url'];
$permalink = $entry['permalink'];
if($counter > 6) {
break;
}
?>
<article class="tw-status">
<div class="tw-content">
<a href="<?= $permalink; ?>" target="_blank"><img alt="" class="insta_image" src="<?= $mediaurl; ?>" width="100%"/></a>
</div>
</article>
<?php endforeach; ?>
<p></p>
<?php
endif;
else:
echo 'No posts available.';
endif;
?>
希望它对您有帮助。