admin管理员组文章数量:1415100
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.
本文标签: Get ACF options field in PHP acting as CSS
版权声明:本文标题:Get ACF options field in PHP acting as CSS 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745188635a2646803.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论