Home Forums General Issues Access acf functions in custom php file


Access acf functions in custom php file

  • Hello,

    I have a custom php file in wordpress child-theme, where i need to retrieve a custom field from a post (custom post type). I call get_field() function but i get error that there is no this function. I suppose this is happening because the file can’t see acf functions. How i could solve this problem and run acf methods?

    Thanks for your help

  • Is this file running independently, without WP? That’s the only thing I can think of that will cause this.

  • This file i running independently, it’s custom and i want this file to run only when there is a woocommerce order. This file i just for retrieving a value (custom field) according to post id. I call wp-load on my file but with this a can just user wordpress function..not from plugin.

    Can i run acf function in my case?

  • This is the only thing I can find.

    The general thought I get from most other pages is to not do this.

    I would probably look for another way to do this without bypassing WP. If you’re going to load all the plugins anyway you may as well load WP. But If I had to do it I would probably use get_post_meta() to get my values instead of using the ACF functions.

  • Thank you very much, it’s working great. That was very helpful!!

Viewing 5 posts - 1 through 5 (of 5 total)

The topic ‘Access acf functions in custom php file’ is closed to new replies.