Get ACF options field in PHP acting as CSS

I am combining all of my css files into one file via PHP usingheader('Content-type: textcss');Within that pro

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 badges
Add a comment  | 

1 Answer 1

Reset to default 1

I'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

相关推荐

  • Get ACF options field in PHP acting as CSS

    I am combining all of my css files into one file via PHP usingheader('Content-type: textcss');Within that pro

    11小时前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信