• Resolved stevehtz

    (@stevehtz)


    This code on my static homepage displays recent posts:

    <?php
       $postslist = get_posts('numberposts=10');
       foreach ($postslist as $post) {
          setup_postdata($post);
       ?>
        <div class="post-wrapper">
          <?php the_content(); ?>
        </div>
      <?php } ?>

    …and in the next section on the page I am calling some custom fields from CFS including a loop. The above code causes the custom fields to not display their data, and I have narrowed it down to the issue being something to do with $post in the above code because when it is eliminated, the custom fields display their data properly. Here is the code for the custom fields.

    <?php
        $loop = CFS()->get('questions');
        foreach ( $loop as $row ) {
      ?>
        <div class="faq content-col">
          <h6><?php echo $row['question']; ?></h6>
          <p><?php echo $row['intro_text']; ?></p>
          <?php echo $row['link']; ?>
        </div>
      <?php } ?>

    Thank you in advance for your help! This forum has been AMAZING at helping with WordPress CFS.

    https://www.ads-software.com/plugins/custom-field-suite/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi Steve,

    Have you tried using the post ID in the call to CFS()->get(‘questions’), as in CFS()->get(‘questions’, MyPostID)???

    I’ve found that sometimes its necesary to address the post ID specifically.

    Best regards,
    -Orallo

    Thread Starter stevehtz

    (@stevehtz)

    That worked perfectly. Thank you so much for your quick response!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘$post is causing $loop = CFS()->get() to not work properly’ is closed to new replies.