Home › Forums › Front-end Issues › ACF fields returning NULL
Hi there,
I think it is easier to show my setup in a video:
I tried get_field and the_field as well, but they both return null.
What can cause this?
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.
You must be logged in to reply to this topic.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.