Answer the question
In order to leave comments, you need to log in
How to output an ACF entry object?
Hello. Worth the plugin Advanced Custom Fields. The Flexible Content addon is also connected to it. Flexible content.
I cannot deduce a field with object of record in any way. The site template simply does not load further, although it displays simple text fields calmly.
<?php
// check if the flexible content field has rows of data
if( have_rows('products') ):
// loop through the rows of data
while ( have_rows('products') ) : the_row();
if( get_row_layout() == 'list' ):
the_sub_field('price'); ---- обычное текстовое поле
the_sub_field('author_rating'); ---- обычное текстовое поле
elseif( get_row_layout() == 'download' ):
$file = get_sub_field('file');
endif;
endwhile;
else :
// no layouts found
endif;
?>
the_sub_field('object');
Answer the question
In order to leave comments, you need to log in
Hello!
It would not hurt to tell you exactly where you want to display it.
For example, if you have created flexible content as an option (for example, for the "Theme Options" section), the example is https://www.advancedcustomfields.com/add-ons/optio...
then you need to pass 'option' to flexible content
If you display it on one page in the admin panel, but want to display it on another page, then you need to pass the page ID there.
And if you display it in the admin panel and display it on the same page, then you do not need to specify anything.
Here, an example of flexible content is given -
https://www.advancedcustomfields.com/resources/fle... I
also recommend enabling debugging in wp-config.php and looking at PHP errors.
Also try updating the plugin just in case. For example, in my ACF Pro flexible content goes inside the plugin. And everything works.
Well --- the_sub_field() is equal to echo get_sub_field()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question