Home Forums General Issues ACF displays nothing


ACF displays nothing

  • Hello.
    I have problem with my ACF. ACF does not return any text or image.
    I think i configured everything well, but it does not work :/. I dont have any error or something.
    This is the code:

     <?php $image = the_field('image');?>
      <img src="<?php echo $image['url']; ?>">
       <h3>Lorem ipsum</h3><p class="last"> <?php  the_field('text'); ?>  

    This is a Group in Custom Fields
    and this is a page .

    On the site looks like this

    ACF Version 4.4.5
    Thanks for any help.

  • Hi @major

    You can’t use the the_field() function to store the custom field value in a variable. Please use the get_field() function instead. It should be something like this:

    <?php $image = get_field('image');?>
    <img src="<?php echo $image['url']; ?>">
    <h3>Lorem ipsum</h3><p class="last"> <?php the_field('text'); ?>

    I hope this helps.

  • Thanks for answer.
    I do what you said, but unfortunately this change nothing has changed.

  • Hi @Major,
    That is quite odd, it is possible that you have not correctly implemented the code.

    Also ensure that you have correctly set the location settings such as to show on your template page.

    Kindly share with us the code so that I may test it on my end.

    Hope to hear from you soon.

  • This reply has been marked as private.
  • Hi @major
    Everything is now working as expected.
    Kindly check to confirm and let me know

  • Wow, Thank you very much @James. I am realy happy.
    Can you tell me what i do wrong? I don’t want make this misstake second time.

  • Hi @major
    The problem was with the post id.

    You were using the homepage as the latest post page.

    The Page id that was returned was wrong and thus the_field function was returning false

    In case you face another problem, feel free to let me know and I will be glad to help.

  • Thank you again @James.
    I hope I will have not more problems like this.
    If i have a problem I will tell you.

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

The topic ‘ACF displays nothing’ is closed to new replies.