I'm trying to get ACF field that is part of an ACF block in a Page I've created, say "Home Page". I'm trying to do this from the footer, but with no success.
I've tried the following:
I got the "post" id (despite it's a page) from the url in the admin console:
/wp-admin/post.php?post=7&action=edit
. My code may seem strange, it's a php blade template, I'm using Root.io Sage theme.
{{ the_field('hours-o-mo', 7) }}
and
@php
the_field('hours-o-mo', 7)
@endphp
I haven't "registered" any blocks, per se, I'm just using this plugin ( ) to make template-only acf blocks, that automatically show in my Gutenberg page builder.
I've also tried get_field
. I'm not sure what I'm doing wrong, it should be simple to get an ACF field from a specific page, from the footer. Right?
I'm trying to get ACF field that is part of an ACF block in a Page I've created, say "Home Page". I'm trying to do this from the footer, but with no success.
I've tried the following:
I got the "post" id (despite it's a page) from the url in the admin console:
/wp-admin/post.php?post=7&action=edit
. My code may seem strange, it's a php blade template, I'm using Root.io Sage theme.
{{ the_field('hours-o-mo', 7) }}
and
@php
the_field('hours-o-mo', 7)
@endphp
I haven't "registered" any blocks, per se, I'm just using this plugin ( https://github/MWDelaney/sage-acf-wp-blocks ) to make template-only acf blocks, that automatically show in my Gutenberg page builder.
I've also tried get_field
. I'm not sure what I'm doing wrong, it should be simple to get an ACF field from a specific page, from the footer. Right?
1 Answer
Reset to default 1I have the same issue, the acf get_field() function in footer returned null. Native WP function get_post_meta( get_the_ID(), 'option_key', true ) didn't work to. But when I've noticed that get_the_ID() function in footer returned the wrong value because I forgot to reset query after custom WP_Query. So, reset custom WP_Query (wp_reset_query()) or hard code the page ID.
hours-o-mo
and that the post has a value for that field? – Sally CJ Commented Jul 17, 2019 at 6:42