我正在尝试将jSquares与wordpress集成,我遇到了几个问题。我是一名初学者,但我很想解决这个问题,这样任何人都可以将jSquares与Wordpress结合使用。jSquares信息可以在这里找到:boedesign。com/blog/2009/10/22/jsquares for jquery/
这是我目前的代码:
<div id="js-container">
<? $boxes = array(
// sizes are styled through css and top, left css attributes are hard-coded on the div
array(\'size\' => 3, \'top\' => 0, \'left\' => 0),
array(\'size\' => 2, \'top\' => 0,\'left\' => 224),
array(\'size\' => 2, \'top\' => 78, \'left\' => 224),
array(\'size\' => 3, \'top\' => 0, \'left\' => 336),
array(\'size\' => 2, \'top\' => 0, \'left\' => 560),
array(\'size\' => 2, \'top\' => 78, \'left\' => 560),
array(\'size\' => 2, \'top\' => 156, \'left\' => 0),
array(\'size\' => 3, \'top\' => 156, \'left\' => 112),
array(\'size\' => 2, \'top\' => 156, \'left\' => 336),
array(\'size\' => 1, \'top\' => 156, \'left\' => 448),
array(\'size\' => 1, \'top\' => 195, \'left\' => 448),
array(\'size\' => 2, \'top\' => 156, \'left\' => 504),
array(\'size\' => 1, \'top\' => 156, \'left\' => 616),
array(\'size\' => 1, \'top\' => 234, \'left\' => 56),
array(\'size\' => 1, \'top\' => 234, \'left\' => 336)); ?>
<?php
query_posts(array(
\'showposts\' => 15,
\'post_type\' => \'page\',
\'posts_per_page=15\',
\'orderby\' => \'rand\',
\'post__not_in\' => array(33,145,31,148,109,111,113,29,209)));
if (have_posts()) : while (have_posts()) : the_post();
foreach ($boxes as $box); ?>
<div class="js-image size-<?= $box[\'size\']; ?>" style="top:<?= $box[\'top\']; ?>px;left:<?= $box[\'left\']; ?>px;">
<a href="<?php the_permalink(); ?> "><img class="js-small-image" src="<? $image = wp_get_attachment_image_src ( get_post_thumbnail_id ( $post_id ), \'single-post-thumbnail\' ); echo $image[0]; ?>"/></a>
<div class="js-small-caption">
<span><?php the_title(); ?></span>
</div>
<div class="js-overlay-caption-content">
<h4><?php the_title(); ?></h4>
<p>
<a href="<?php the_permalink(); ?>">Read</a>
</p>
</div>
</div>
<?php endwhile; endif; ?>
但是foreach($box作为$box)只反映了$box的最后一个数组,而不是每个数组中的一个。我希望这是有意义的。如果您有任何建议,我们将不胜感激!!
谢谢你的建议!我在这里:
<?php $query = new WP_Query(
array(\'showposts\' => 15,
\'post_type\' => \'page\',
\'posts_per_page=15\',
\'orderby\' => \'rand\',
\'post__not_in\' => array(33,145,31,148,109,111,113,29,209)));
foreach($query->$boxes as $box );
while ($query->have_posts()) : $query->the_post() ; ?>
我感谢你的帮助。我试着把这方面的知识教给自己,并把它发布给其他人使用。我仍然被卡住-为foreach()提供的参数无效