A
A
Alexander Novikov2015-11-12 00:44:18
PHP
Alexander Novikov, 2015-11-12 00:44:18

How to display fields from ACF in functions.php file in wordpress?

The people, tell me, created options for the page using the Advanced Custom Fields Plugin for WordPress. You need to display them in functions.php (for get_field() to work, etc.) I will place the code in functions.php (for example)

<?php $field = get_field('ремонт_рабочие'); ?>
  
  <? foreach($field as $fields){ ?>
        <li data-thumb="">
          <img src="<?php echo $fields['фото_рабочего'];?>" height="140" width="220" alt="">
        </li>
      <? } ?>
      </ul>
  
  
  
  </div>

I send the code to the page, it comes stupidly HTML (a wrapper for this PHP).
That is, the value of this Field has not been received....
Maybe you need to somehow connect the Field Group or something else to functions.php ?
Thanks for the help.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
Nick Murzin, 2015-11-12
@R0s0maxa

Чтобы получить со страницы опций - юзаем:
Не забываем курить ман

Юрий, 2015-11-12
@kapitan7830

get_field(название поля, id страницы)
Если вы используете эту функцию внутри цикла то id указывать не обязательно. А если в functions.php, то нужно указать id страницы, поля которой вы хотите получить.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question