0

my php skills are pretty limited and I am pretty much stuck with the following issue.

Why is my Custom Field (placed at the bottom) not showing up after the posts blocks? Here is what my code looks like:

<!-- 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>
  • Where does it show up? – s_ha_dum Apr 16 '15 at 16:12
  • It doesn't show up at all. Something is conflicting between the 3 columns and the Custom Field at the bottom. – Vibrains Apr 16 '15 at 16:14
3

Your custom loop $catquery will override the "current" post, and so the_field will operate on the last post of that loop.

Call wp_reset_postdata() right after your loop is finished (after endwhile;). This will restore the post global to the true "current" post.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.