0

How can I access a Carbon Fields value using the function carbon_get_post_meta from within a namespace?

If I do:

if ( function_exists( 'carbon_get_post_meta' ) ):
    echo 'true';
else:
    echo 'false';
endif;

Then I get false, but if I check for the function inside of page.php with the same code, then it returns true.

I have tried checking for '\carbon_get_post_meta' as well but the result is the same.

Please can someone point me in the right direction.

EDIT:

This is the framework I'm using https://github.com/seothemes/genesis-starter-theme inside of lib I set up carbon fields inside of the plugins directory, and called it inside init.php, I know this is working because I have set up some post meta using carbon fields, but when I try to access the data from within lib/plugins with the namespace namespace SeoThemes\GenesisStarterTheme\Plugins it says that the function is undefined

Hope this helps?

Stuart
  • 45
  • 8

1 Answers1

0

As far as I know it was supposed to be working, try this please

if ( \function_exists( 'carbon_get_post_meta' ) ):
    echo 'true';
else:
    echo 'false';
endif;
Kelvin Mariano
  • 991
  • 8
  • 15
  • Thank you, I had tried this as well but I still get false, I see function_exists does work as intended if I try something else like is_single or something, just not with carbon_get_post_meta :/ – Stuart Oct 29 '19 at 23:03
  • please post how is your complete code please it may be that the way you are using the function has not been created yet – Kelvin Mariano Oct 29 '19 at 23:06