I am combining all of my css files into one file via PHP using
header('Content-type: text/css');
Within that processed PHP file, I want to get a field from an options page within Advanced Custom Fields.
the_field('field_name', 'option');
Even though I can successfully call the field in the section in 'header.php', I can't get it within the PHP file processing my css. Is there a way to do this?
I am combining all of my css files into one file via PHP using
header('Content-type: text/css');
Within that processed PHP file, I want to get a field from an options page within Advanced Custom Fields.
the_field('field_name', 'option');
Even though I can successfully call the field in the section in 'header.php', I can't get it within the PHP file processing my css. Is there a way to do this?
Share Improve this question asked Sep 3, 2019 at 18:52 jonsjons 1291 silver badge5 bronze badges1 Answer
Reset to default 1I'm not sure what exactly your setup is or where this file is but ACF saves its values as post meta. So you could simply use WP's get_post_meta() if ACF isn't available.
For Example:
get_post_meta( get_the_ID(), 'field_name', true );
You can also have a look at this article, it talks about using get_post_meta vs ACF functions.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745188635a4615756.html
评论列表(0条)