Support

Account

Home Forums Front-end Issues ACF fields returning NULL

Solving

ACF fields returning NULL

  • Hi there,

    I think it is easier to show my setup in a video:

    https://youtu.be/v-k8hhw93Go

    I tried get_field and the_field as well, but they both return null.
    What can cause this?

  • I have exactly the same issue… Have you found the solution?

  • Hi there,

    Honestly, I don’t remember exactly what I did, but this code works now (I might have had to recreate the fields)

    <?php
    $my_current_lang = apply_filters( ‘wpml_current_language’, null );
    // $queried_object = get_queried_object();
    // var_dump( $queried_object );
    ?>

    <?php
    
    		$loop = new WP_Query(
    			array(
    				'post_type' => 'page',
    				'post__in'  => array( 21 ),
    			)
    		);
    		?>
    <?php
    while ( $loop->have_posts() ) :
    	$loop->the_post();
    	$rolunkbg   = get_field( 'aboutus_bg' );
    	$rolunktext = get_field( 'aboutus_text' );
    
    	?>
    
    <div class="container-fluid bg1 slanted2" style=" background-image:url('<?php echo wp_get_attachment_url( $rolunkbg ); ?>">
        <div class="container tagline">
    
            <h4 class="tagline--description"><?php echo $rolunktext; ?></h4>
    
            <?php endwhile; ?>
            <!-- ;" width="45"> -->
    
            <h2 class="tagline--h2 tagline--transparent">
                <?php
    			if ( $my_current_lang == 'en' ) {
    
    				?>
                <!-- ABOUT US -->
                <?php
    			} else {
    				?>
                <!-- Rólunk -->
                <?php
    			}
    			?>
            </h2>
            <h3 class="tagline--subheadline pt-2 text-center">
                <?php
    			if ( $my_current_lang == 'en' ) {
    				?>
                A professzionális audiovizuális megoldások forrása.
                <?php
    			} else {
    				?>
                A professzionális audiovizuális megoldások forrása.
                <?php
    			}
    			?>
            </h3>
            <h2 class="tagline--h2">
                <?php
    			if ( $my_current_lang == 'en' ) {
    				?>
                <!-- ABOUT US -->
                <?php
    			} else {
    				?>
                <!-- Rólunk -->
                <?php
    			}
    			?>
            </h2>
    
            <?php if ( $my_current_lang == 'en' ) { ?>
            <div class="row">
                <div class="col-3"></div>
                <div class="col-6"><a href="about">
                        <div class="btn-primary text-center">About us</div>
                    </a></div>
                <div class="col-3"></div>
            </div>
            <?php } ?>
    
            <?php if ( $my_current_lang == 'hu' ) { ?>
            <div class="row">
                <div class="col-3"></div>
                <div class="col-6"><a href="rolunk">
                        <div class="btn-primary text-center">Rólunk</div>
                    </a></div>
                <div class="col-3"></div>
            </div>
            <?php } ?>
        </div>
    </div>

    Let me know if it does not help and I’ll check if I needed to change something with the fields in admin.

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

You must be logged in to reply to this topic.