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:

  • Tyler Orr
    • Site Builder, Child of Zeus

    If I wrap it anywhere outside of where it is listed in the code below it breaks the layout of the theme or gives me the following error:

    Fatal error: Cannot break/continue 1 level in /home/creativ3/public_html/developer/insightpedia/wp-content/themes/bangkokpress/page.php on line 35

    Code is

    if(get_field('pick_your_theme') != "MacroForces"){ continue; }

    Additionally, it doesn’t seem to be passing the if statement as this is saying it should contain the selector of “MacroForces” but the posts being shown do not have that as the selected value.

    if ( have_posts() ){
    while (have_posts()){ the_post();

    if( $gdl_show_title != "No" ){
    echo '<div class="sixteen columns mb0">';
    echo '<div class="page-header-wrapper">';
    echo '<h1 class="page-header-title title-color gdl-title">' . get_the_title() . '</h1>';
    echo '<div class="header-gimmick mr0"></div>';
    echo '<div class="clear"></div>';
    echo '</div>';
    echo '</div>'; // sixteen columns

    if( $page_background != 'No' ){
    echo "<div class='sixteen columns'>";
    echo '<div class="page-bkp-frame-wrapper">';
    echo '<div class="page-bkp-frame">';

    if(get_field('pick_your_theme') != "MacroForces"){ continue; }

    $content = get_the_content();
    // Show content
    if( $gdl_show_content != 'No' && !empty($content) ){
    echo '<div class="sixteen columns">';
    echo '<div class="gdl-page-content">';
    echo '<div class="bkp-frame-wrapper">';
    echo '<div class="bkp-frame p20">';
    echo '</div>';
    echo '</div>';
    echo '</div>'; // page-content
    echo '</div>'; // sixteen columns

    } // while loop

    } //if have posts

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.