-1

I have my Flexile Content layout with custom fields:

<h2 class="mb-half"><?php the_sub_field('form_two_title')?></h2>
<p class="mb-3 lead"><?php the_sub_field('form_two_text')?></p>

and I need to write them in my custom function of functions.php witch echo.

First of all, I need to find a way to call that layout, but is it possible to write custom fields in echo section?

I have something in that way:

echo '<h2 class="mb-half">.the_sub_field('form_two_title').</h2>';

but compiler do not recognize "form_two_title" constant.

Do I need to call get_row_layout()?

0

1 Answer 1

0

The code you are calling is not a valid PHP:

echo '<h2 class="mb-half">.the_sub_field('form_two_title').</h2>';

Try fixing it like this:

echo '<h2 class="mb-half">'.get_sub_field('form_two_title').'</h2>';
Sign up to request clarification or add additional context in comments.

7 Comments

good advice, it is working, but form_two_title is empty, do I need to call get_row_layout() ? cause that content field is on my page template. but here his values are not recognized
The correct syntax for your function should be described here: advancedcustomfields.com/resources/the_sub_field
When you are using echo you should go for get_sub_field, without echo it is the_sub_field. I updated the answer.
Already tried that, all get_row_layouts are in switch on my Template page, but in fucntions.php I can not write data, cause In some reason they do not exist
What do you mean exactly by "cannot write data"? Can you update your question with the code you have in your functions.php ?
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.