Wordpress ACF get_field( ) not returning value

笑着哭i 提交于 2019-12-05 08:06:55

If you're using WP_Query() before using get_field(), you need to reset the query using wp_reset_query() function. I hope it'll solve this issue.

You're using get_the_ID() outside of the loop.

http://codex.wordpress.org/Function_Reference/get_the_ID

You could try:

global $post;
the_field( 'the-title', $post->ID );

But this would depend on what page you're on.

Which template file is this being used in?

Raul Martin

You need to create a loop, then inside that loop you can retrieve the data.

<?php while( have_posts() ) : the_post() ?>
     <?php $variable = the_field('the-title'); ?>
<?php endwhile; ?>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!