2011-12-08 74 views
1

使用magicfields 2.0插件的Wordpress 3.1。
这里的损毁页: http://sseko.wecreativeagency.com/style/Magicfields foreach没有停止,迭代太多

,这里是一个网页,它的工作:
http://sseko.wecreativeagency.com/university-bound/

注意第一页的页脚从magicfields收到的ID信息

<?php get_header(); ?> 
<div id="content"> 
<?php if (have_posts()) : while (have_posts()) : the_post(); ?> 

    <article id="post-<?php the_ID(); ?>"> 

      <?php the_content(); ?> 
      <div id="note" class="grid_12"><p class="note grid_6 alpha"><span class="special">Style your Ssekos!</span> There are so many ways to tie your Ssekos. Watch the videos and learn how! Then, come up with your own!</p><h1 class="grid_6 omega"><?php wp_title(' ','true','right'); ?></h1></div>     
      <?php $styles = getFieldOrder('image'); 
           if(is_array($styles)) 
           {foreach($styles as $style) 
            { 
            echo "<div class='grid_3'>"; 
            echo "<a rel='styles' href='#info$style'class='inlineimg grid_3'>"; 
            echo "<img src='"; 
            echo get_image('image',1,$style,$tag_img=0); 
            echo "'class='grid_3' title='"; 
            echo get('name',1,$style); 
            echo "'alt='"; 
            echo get('name',1,$style); 
            echo "'";          
            echo "</a>"; 
            echo "<h2 class='grid_3'>"; 
            echo get('name',1,$style); 
            echo "</h2></div>"; 
            echo "<div style='display:none'><div id='info$style' class='grid_8 lightbox'>"; 
            echo get('link',1,$style); 
            echo "</div></div>"; 

            } 
           } 
           ?> 
    <div class="clear"></div> 
    </article> 
    <?php endwhile; endif; ?> 

我已经检查数据库的额外条目,但我找不到它继续迭代到下面的元素的原因。

回答

2

由于某种原因,我无法检查您的网站..但我相信这是发髻,因为您有2个嵌套循环。 一个是Wordpress循环,如果 - > while,然后是您的Foreach循环。 当WordPress的循环遇到帖子,它会迭代你的第二个循环为每个职位... 例如,在有10 $职位的页面上,它将迭代10次每个$样式... 当你有1篇文章时,它会迭代一次。 就像我说的,由于某种原因,您的网站不适用于我,但看到您的网址构建,我的猜测是它不适用于第一个例子,因为它是某种类别(它返回多个帖子)和第二个网址是单个帖子...