in_caterogy在更改发布日期/时间后不会显示

时间:2015-10-18 14:18:11

标签: php wordpress

Wordpress在这里表现得非常奇怪,超出了我的理解!

所以有这4个帖子: enter image description here 这就是我在我的网站上展示它们的方式: enter image description here

正如您所看到的,它只会显示来自' Events'类别。这是正确的!见代码:

     if (have_posts())
            {
                while (have_posts()) : the_post();
                    if (in_category( 'Events' )) {
                        $haveEvents = true;
                        **if ($eventCount < 3) {**
                            $eventCount++;
                            ?>
                            <div class="event-tile">
                                <div class="event-tile-content">
                                    <h3><?php the_title(); ?></h3>
                                    <h4><?php the_time('F jS, Y'); ?></h4>
                                    <a href="<?php the_permalink(); ?>" class="event-tile-read-more">Lees meer</a>
                                </div>
                            </div>
                            <?php
                        }
                    }
                endwhile;
            }

我还有一些其他类别,因此我使用多个have_posts循环来显示每个类别的帖子。

现在,在我为每个类别添加了一些新帖子之后,&#39;事件&#39;帖子哪里不见了。我测试了大约一个小时左右,我发现了问题,由于某种原因,循环有麻烦,以显示更老的&#39;帖子(属于&#39;事件&#39;类别)。

这里我要证明我的意思: 更改了已发布的&#39;时间,所以帖子是最老的&#39;: enter image description here 在做出这个改变之后,帖子就消失了...... enter image description here

我不明白Wordpress的这种奇怪行为。 如代码所示;

  1. loop trow posts
  2. 如果发布类别&#39;事件&#39;继续 - &gt;
  3. if&#39; eventCount&#39;小于3 - >显示
  4. &#39; EVENTCOUNT&#39; ++
  5. 我犯了错误吗? wordpress有问题吗?

0 个答案:

没有答案