Home Forums General Issues Pass Advanced Custom Fields Through Blog Loop


Pass Advanced Custom Fields Through Blog Loop

  • I’m hoping that someone can help me out here. I am trying to get ACF integrated into a Theme a client purchased.

    The basic functionality is that I have built a custom field on every post to choose where to place the post. Thus, if they choose “Option A” in the post, then the code needs to check for that option to be true before passing all of the content related to the post (Title, Content, Images, etc.)

    A basic code example of how this would work in a standard php document would be as follows:

    <?php if (have_posts()): while (have_posts()) : the_post(); ?>
    <?php if(get_field('pick_your_theme') == "Theme1") { ?>
    <h2><?php the_title(); ?></h2>
    <p><?php the_excerpt(); ?></p>
    <?php } ?>
    <?php endwhile; ?>
    <?php endif; ?>

    The issue here is that the theme author has created the page in one giant open PHP function rather than breaking it up (as in example code 1 above) where I can easily insert the selector get_field.

    Below is a link for the PHP code for the page:

  • If I utilize the code linked below, adding the code of:

    `if(get_field(‘pick_your_theme’) != “MacroForces”){ continue; }’

    it doesn’t seem to pass the selector value and still pulls all posts, regardless if they are marked as MacroForces or not.

  • Nevermind, just got it all figured out. Thanks!

  • Good to hear @creativ3group, good luck with your project. 🙂

Viewing 4 posts - 1 through 4 (of 4 total)

The topic ‘Pass Advanced Custom Fields Through Blog Loop’ is closed to new replies.