我希望通过XML发布每3个帖子后回显一个图像这里是我的代码:
<?php
// URL of the XML feed.
$feed = 'test.xml';
// How many items do we want to display?
//$display = 3;
// Check our XML file exists
if(!file_exists($feed)) {
die('The XML file could not be found!');
}
// First, open the XML file.
$xml = simplexml_load_file($feed);
// Set the counter for counting how many items we've displayed.
$counter = 0;
// Start the loop to display each item.
foreach($xml->post as $post) {
echo '
<div style="float:left; width: 180px; …Run Code Online (Sandbox Code Playgroud) 注意:这是一个自我问答
在WordPress中构建不对称网格布局时,通常需要将每个X帖子包装在div中,如下所示:
div
post
post
/div
div
post
post
/div
div
post
post
/div
Run Code Online (Sandbox Code Playgroud)
我想避免使用模运算符,因为它很快就会混淆.