高级自定义字段不显示

时间:2015-04-16 作者:Vibrains

我的php技能非常有限,我几乎被以下问题所困扰。

为什么我的自定义字段(位于底部)没有显示在posts块之后?下面是我的代码:

<!-- 3 COLUMN POSTS -->
<!-- FIRST COLUMN BELOW -->
<div class="row"><!-- Foundation .row start -->
    <div class="large-12 medium-12 columns post-column">
        <h3>What\'s Going On</h3>
    </div>
    <div class="homepage-posts">
        <div class="large-4 medium-4 columns post-column">
            <h2>Upcoming Events</h2>
            <?php
            $catquery = new WP_Query( \'cat=8&posts_per_page=1\' );
            while($catquery->have_posts()) : $catquery->the_post();
            ?>
        <?php endwhile;?>
        <div class="news-excerpt"><p><?php echo excerpt(100); ?></p>
        </div>
        <p><?php echo substr(strip_tags($post->post_content), 0, 150);?> <a href="<?php the_permalink() ?>" rel="bookmark">Read more &raquo;</a></p><br><br>

    </div>

    <!-- SECOND COLUMN BELOW -->
    <div class="large-4 medium-4 columns post-column">
        <h2>Recent Jobs</h2>
        <?php
        $catquery = new WP_Query( \'cat=9&posts_per_page=5\' );
        while($catquery->have_posts()) : $catquery->the_post();
        ?>
    <?php endwhile;?>
    <div class="news-excerpt"><p><?php echo excerpt(100); ?></p>
    </div>
    <p><?php echo substr(strip_tags($post->post_content), 0, 150);?> <a href="<?php the_permalink() ?>" rel="bookmark">Read more &raquo;</a></p><br><br>

</div>

<!-- THIRD COLUMN BELOW -->
<div class="large-4 medium-4 columns post-column">
    <h2>Resources</h2>
    <?php
    $catquery = new WP_Query( \'cat=10&posts_per_page=5\' );
    while($catquery->have_posts()) : $catquery->the_post();
    ?>
<?php endwhile;?>
<div class="news-excerpt"><p><?php echo excerpt(100); ?></p>
</div>
<p><?php echo substr(strip_tags($post->post_content), 0, 150);?> <a href="<?php the_permalink() ?>" rel="bookmark">Read more &raquo;</a></p><br><br>

</div>
</div>
</div>

<div class="row">
    <?php the_field(\'about_blurb\'); ?>
</div>

1 个回复
SO网友:TheDeadMedic

您的自定义循环$catquery 将覆盖“当前”帖子,等等the_field 将在该回路的最后一根立柱上运行。

呼叫wp_reset_postdata() 循环完成后(之后endwhile;). 这将使post global恢复为真正的“当前”post。

结束
高级自定义字段不显示 - 小码农CODE - 行之有效找到问题解决它

高级自定义字段不显示

时间:2015-04-16 作者:Vibrains

我的php技能非常有限,我几乎被以下问题所困扰。

为什么我的自定义字段(位于底部)没有显示在posts块之后?下面是我的代码:

<!-- 3 COLUMN POSTS -->
<!-- FIRST COLUMN BELOW -->
<div class="row"><!-- Foundation .row start -->
    <div class="large-12 medium-12 columns post-column">
        <h3>What\'s Going On</h3>
    </div>
    <div class="homepage-posts">
        <div class="large-4 medium-4 columns post-column">
            <h2>Upcoming Events</h2>
            <?php
            $catquery = new WP_Query( \'cat=8&posts_per_page=1\' );
            while($catquery->have_posts()) : $catquery->the_post();
            ?>
        <?php endwhile;?>
        <div class="news-excerpt"><p><?php echo excerpt(100); ?></p>
        </div>
        <p><?php echo substr(strip_tags($post->post_content), 0, 150);?> <a href="<?php the_permalink() ?>" rel="bookmark">Read more &raquo;</a></p><br><br>

    </div>

    <!-- SECOND COLUMN BELOW -->
    <div class="large-4 medium-4 columns post-column">
        <h2>Recent Jobs</h2>
        <?php
        $catquery = new WP_Query( \'cat=9&posts_per_page=5\' );
        while($catquery->have_posts()) : $catquery->the_post();
        ?>
    <?php endwhile;?>
    <div class="news-excerpt"><p><?php echo excerpt(100); ?></p>
    </div>
    <p><?php echo substr(strip_tags($post->post_content), 0, 150);?> <a href="<?php the_permalink() ?>" rel="bookmark">Read more &raquo;</a></p><br><br>

</div>

<!-- THIRD COLUMN BELOW -->
<div class="large-4 medium-4 columns post-column">
    <h2>Resources</h2>
    <?php
    $catquery = new WP_Query( \'cat=10&posts_per_page=5\' );
    while($catquery->have_posts()) : $catquery->the_post();
    ?>
<?php endwhile;?>
<div class="news-excerpt"><p><?php echo excerpt(100); ?></p>
</div>
<p><?php echo substr(strip_tags($post->post_content), 0, 150);?> <a href="<?php the_permalink() ?>" rel="bookmark">Read more &raquo;</a></p><br><br>

</div>
</div>
</div>

<div class="row">
    <?php the_field(\'about_blurb\'); ?>
</div>

1 个回复
SO网友:TheDeadMedic

您的自定义循环$catquery 将覆盖“当前”帖子,等等the_field 将在该回路的最后一根立柱上运行。

呼叫wp_reset_postdata() 循环完成后(之后endwhile;). 这将使post global恢复为真正的“当前”post。

相关推荐

无法在模板函数.php中使用IS_HOME

我试图在标题中加载一个滑块,但只在主页上加载。如果有帮助的话,我正在使用Ultralight模板。我正在尝试(在template functions.php中)执行以下操作:<?php if ( is_page( \'home\' ) ) : ?> dynamic_sidebar( \'Homepage Widget\' ); <?php endif; ?> 但这行不通。现在,通过快速的google,我似乎需要将请