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

  • Thank you. Do you have an example of how to use get_post_meta() with ACF data? – jons Sep 3 at 19:24
  • I updated the answer – RiddleMeThis Sep 3 at 19:33
  • Thank you so much @riddlemethis. I appreciate your time very much! – jons Sep 3 at 23:06
  • It wasn't working on first try. I don't have a post_id because it is coming from an Options page in ACF Pro. It is my understanding that the string 'option' or 'options' is used in that case. But that was not working either. – jons Sep 4 at 2:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.